ln.templates/ln.templates/html/ExpressionElement.cs

41 lines
1.0 KiB
C#

// /**
// * File: ExpressionElement.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using ln.templates.script;
using System.IO;
namespace ln.templates.html
{
public class ExpressionElement : TemplateElement
{
public string ExpressionText { get; }
public NewExpression Expression { get; }
public ExpressionElement(string expression)
:base("#expression")
{
ExpressionText = expression;
Expression = new NewExpression(ExpressionText);
}
public override void Render(TextWriter writer)
{
writer.Write("{{{{{0}}}}}", ExpressionText);
}
public override void RenderTemplate(RenderContext renderContext)
{
object o = Expression.Resolve(renderContext);
renderContext.ContentWriter.Write(o?.ToString());
}
}
}