Permalink
Browse files

delegate method on render level 0

  • Loading branch information...
1 parent 141e0b3 commit abc97f73ee25b753ae745647eacdafdea0f3e22c @leon-andria leon-andria committed Jan 4, 2013
Showing with 14 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +9 −3 src/Spark/Compiler/CSharp/CSharpViewCompiler.cs
  3. +4 −0 src/Spark/SparkViewBase.cs
View
@@ -20,6 +20,7 @@ _ReSharper.*
*.dotCover
*.ncrunchproject
*crunchsolution*
+*.disposechecksettings
# Ignore all MonoDevelop generated files.
*.userprefs
@@ -144,12 +144,18 @@ public override void GenerateSourceCode(IEnumerable<IList<Chunk>> viewTemplates,
{
if (invokeLevel != renderLevel - 1)
{
- source.WriteLine("using (OutputScope()) {{RenderViewLevel{0}(); Content[\"view\"] = Output;}}", invokeLevel);
+ source.WriteLine("using (OutputScope()) {{DelegateFirstRender(RenderViewLevel{0}); Content[\"view\"] = Output;}}", invokeLevel);
}
else
{
-
- source.WriteLine(" RenderViewLevel{0}();", invokeLevel);
+ if (renderLevel <= 1)
+ {
+ source.WriteLine(" DelegateFirstRender(RenderViewLevel{0});", invokeLevel);
+ }
+ else
+ {
+ source.WriteLine(" RenderViewLevel{0}();", invokeLevel);
+ }
}
}
source.RemoveIndent().WriteLine("}");
@@ -241,6 +241,10 @@ public virtual void RenderView(TextWriter writer)
}
public abstract void Render();
+ protected virtual void DelegateFirstRender(Action render)
+ {
+ render();
+ }
}
}

0 comments on commit abc97f7

Please sign in to comment.