Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what I wanted the ASP.NET MVC ViewEngine to do, but it's in Spark, just follow the latest link right bellow,</p> <p><strong>Update (12/30/2009) Cleaner Version:</strong> <a href="http://andrewblogs.com/blog/asp-net-mvc-email-solution/" rel="nofollow noreferrer">ASP.NET MVC Email Template Solution</a></p> <hr> <p><strong>(11/16/2009)</strong> Or, Louis DeJardin Console Application Version:</p> <pre><code>using System; using Spark; using Spark.FileSystem; public class User { public int Id { get; set; } public string Name { get; set; } } public abstract class EmailView : AbstractSparkView { public User user { get; set; } } class Program { static void Main(string[] args) { // following are one-time steps // create engine var settings = new SparkSettings() .SetPageBaseType(typeof(EmailView)); var templates = new InMemoryViewFolder(); var engine = new SparkViewEngine(settings) { ViewFolder = templates }; // add templates templates.Add("sample.spark", @"Dear ${user.Name}, This is an email.Sincerely, Spark View Engine http://constanto.org/unsubscribe/${user.Id}"); // following are per-render steps // render template var descriptor = new SparkViewDescriptor() .AddTemplate("sample.spark"); var view = (EmailView)engine.CreateInstance(descriptor); view.user = new User { Id = 655321, Name = "Alex" }; view.RenderView(Console.Out); Console.ReadLine(); } } </code></pre> <p>I decided to use this method because it seems to be the one that does everything right, it:</p> <ul> <li>Does not use any HttpContext/ControllerContext or mess with routing data!</li> <li>It can implement Header/Footer to allow templates!</li> <li>You can use loops, conditionals, etc...</li> <li>It's clean, light weight especially if you plan to move entirely to spark view engine!</li> </ul> <p>Please, make sure to read these posts. All credit to Louis DeJardin see his tutorials :): <a href="http://whereslou.com/2008/12/16/using-spark-as-a-general-purpose-template-engine" rel="nofollow noreferrer">Using Spark as a general purpose template engine!</a>, <a href="http://whereslou.com/2009/01/27/late-bound-eval-email-templates-revisited" rel="nofollow noreferrer">Email Templates Revisited</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload