Hi,
back on my initial question about compiling template, i m looking for some
experienced ideas.
I have now found out i needed to change the ast tree of template in order
to simplify it for later manipulation.
So for example i transform this
{{ ("what" | up) | lower }}
into
{{ $some := ("what" | up) }}
{{ $some | lower }}
And so on, i d like to reach
{{ $some := up "what" }}
{{ lower $some }}
Which will be as close as possible to regular go code.
The thing is that the process to do those transformations seems pretty
fragile and tedious.
I have tree like this
parse.Tree
parse.ActionNode
parse.PipeNode
parse.CommandNode
parse.IdentifierNode Ident="up"
parse.StringNode Quoted="\"some\"" Text="some"
parse.TextNode Text="\n"
parse.ActionNode
parse.PipeNode
parse.CommandNode
parse.StringNode Quoted="\"some\"" Text="some"
parse.CommandNode
parse.IdentifierNode Ident="split"
parse.PipeNode
parse.CommandNode
parse.PipeNode
parse.CommandNode
parse.StringNode Quoted="\"what\"" Text="what"
parse.CommandNode
parse.IdentifierNode Ident="lower"
parse.CommandNode
parse.IdentifierNode Ident="up"
parse.TextNode Text="\n"
to simplify, one of the algorithm consist of browsing the structure
until it match a Pipe containing a Cmd with an Identifier after a Cmd with
a Pipe
that would match *("what" | lower) | up*
And so on to simplify more and more the tree.
I wonder if there are better ways to achieve this kind of transform.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.