You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I raised #578 and submitted a PR that received no comment and it looks like the advice now is to use the Visitor supports that's been recently added.
There is an example in the readme but it doesn't demonstrate what I need to do.
I need to walk the template and find instances of a given tag (in my case, {% layout '[id]' %}).
I want to be able to extract both the tag name (layout) and the input ID.
How do I do that using a Visitor?
Starting with a contrived example:
static void Main(string[] args)
{
var template = new MyParser().Parse("{% layout 'layoutid' %}");
var v = new Visitor();
v.VisitTemplate(template);
}
public class Visitor : AstVisitor
{
public override Statement Visit(Statement statement)
{
return base.Visit(statement);
}
}
The Statement method breakpoints but I'm unable to access anything on the statement that is passed in. The only method is WriteToAsync and there are no properties.
How do I extract the statement name and passed parameter?
Cheers
The text was updated successfully, but these errors were encountered:
I will check that. From a brief look at the source the layout tag is of type ParserTagStatement. Maybe filtering statements for this type and then casting would allow you to access the expression it links to. Not sure if this type is public yet.
Hi,
I raised #578 and submitted a PR that received no comment and it looks like the advice now is to use the Visitor supports that's been recently added.
There is an example in the readme but it doesn't demonstrate what I need to do.
I need to walk the template and find instances of a given tag (in my case,
{% layout '[id]' %}
).I want to be able to extract both the tag name (layout) and the input ID.
How do I do that using a Visitor?
Starting with a contrived example:
The
Statement
method breakpoints but I'm unable to access anything on the statement that is passed in. The only method isWriteToAsync
and there are no properties.How do I extract the statement name and passed parameter?
Cheers
The text was updated successfully, but these errors were encountered: