That method will execute during every render. This is the “real-time” part of our sql
tag – each time we render the template, our method runs, and (presumably) queries our database at that moment.
To re-cap, we:
- Told the parser the name of the tag
- Gave it a parser specific to everything after the tag name
- Gave it a method to run when it finds a matching tag
Creating a block is exactly the same process, with two small differences:
- Call
RegisterTagBlock
- The render method takes in an additional input parameter which is a
List<Statement>
representing what was in the block (see the chapter on blocks for examples of how to handle that). So, the signature for that method now looks like this: (sqlTag, i, w, e, c)
If we want to just generally take in named arguments to a tag or block, there is a parser for a list of arguments inside FluidParser
.
Unfortunately, it’s protected
, so we can’t access it directly. Additionally, we can’t just copy it out because – parser combinators working like they do – it’s made up of a bunch of other protected
parsers, which are made up of others, etc.
If we want to use it to define a tag signature, we can extend the parser and expose ArgumentList
, like this: