当我在 DotLiquid 模板中循环一个 IEnumerable 时
{% for block in Blocks -%}
// this works
{{ block.Structure }}
// this doesn't
{% RenderObject block.Structure %}
{% endfor -%}
我可以直接通过渲染成员,block.Structure
但我不知道如何在我自己的标记类中访问此 Structure 对象RenderObject
:
public class RenderObject : Tag
{
private string _tagName;
private string _markup;
public override void Initialize(string tagName, string markup, List<string> tokens)
{
_tagName = tagName;
_markup = markup.Trim();
base.Initialize(tagName, markup, tokens);
}
public override void Render(Context context, TextWriter result)
{
// HERE COMES THE QUESTION
// How to access the block.Structure object here?
var structure = ?