grav-plugin-form
grav-plugin-form copied to clipboard
Added option 'twig' to form field to evaluate label using twig.
Example:
name:
label: 'Name (See [documentation]({{ page.route }}))'
placeholder: 'Your Name'
autocomplete: 'on'
type: text
twig: true
markdown: true
Combined with https://github.com/getgrav/grav/pull/3139 this becomes very powerful, as you can use theme_var('doc_route') to load url settings (and other stuff) here dynamically.
This approach is a good and granular idea, however it will get very messy to implement. I think the core issue currently is the naming conflict evaluate vs twig.
In my PRs this means:
evaluateparses thedefaultvalue using twigtwigparses thelabelfield with twig, andtextforsections
I think you are right: they should be named the same. What about "renaming" evaluate to twig and enable optional twig (and markdown) support for all static fields (no user interaction). This means twig would:
- Make
labels twig compatible - Make
helptexts twig compatible - Make
defaultvalues twig compatible - Make any other static fields like
textortitleofsectiontwig compatible - And it would let us keep backward compatibility for the
hiddenfield (usingevaluateinstead ofevaluate_twig), but also add the newtwigname for the "better"evaluate_twigfunction
The name twig sounds correct here, as it is also used in pages via process.twig or process.markdown.
my_field:
label: '**label** {{ page.title }}'
default: 'also **markdown**'
markdown: true
twig: true
Again, i'll take a look at this after the next release.