I am doing a similar thing to Richard, and after having made some
progress I have hit a little (or big blip) ...
Using the code you put above , I am unsure of how to do several things
but lets get this one working first:
1. As per the docs Under "General Syntax -> Including Code": the
following line of code should work in say "User.spark",
${Guid.NewGuid().ToString("n")}
However I get the following error
Dynamic view compilation failed.
c:\ProjectName\SparkContent\User.spark(3,17): error CS0103: The name
'Guid' does not exist in the current context
1
2 [global::Spark.SparkViewAttribute(
3 Templates = new string[] {
4 "User.spark"
5 })]
6 public class View49f7e8b8610b4aa3b7417f07cca53756 :
LateRooms.Web.Components.Search.BaseView
7 {
8
9 public override System.Guid GeneratedViewId
10 { get { return new System.Guid
("49f7e8b8610b4aa3b7417f07cca53756"); } }
11
12 public void RenderViewLevel0()
13 {
14 #line hidden
15 Output.Write("\r\nDear ");
16 #line default
17 try
18 {
19 #line 2 "C:\ProjectName\SparkContent\User.spark"
20 Output.Write(user.Name);
21 #line default
22 }
23 catch(System.NullReferenceException)
24 {
25 Output.Write("${user.Name}");
26 }
27 #line hidden
28 Output.Write(",\r\n<p>");
29 #line default
30 try
31 {
32 #line 3 "C:\ProjectName\SparkContent\User.spark"
33 Output.Write(Guid.NewGuid().ToString("n"));
34 #line default
35 }
36 catch(System.NullReferenceException)
37 {
38 Output.Write("${Guid.NewGuid().ToString(\"n\")}");
39 }
40 #line hidden
41 Output.Write("</p>\r\nThis is an email.\r\n\r\nSincerely,\r
\nSpark View Engine\r\n\r\nhttp://
constanto.org/unsubscribe/");
42 #line default
43 try
44 {
45 #line 9 "C:\ProjectName\SparkContent\User.spark"
46 Output.Write(user.Id);
47 #line default
48 }
49 catch(System.NullReferenceException)
50 {
51 Output.Write("${user.Id}");
52 }
53 }
54
55 public override void RenderView(System.IO.TextWriter writer)
56 {
57 using (OutputScope(writer)) {RenderViewLevel0();}
58 }
59 }
Thanks
W