On Sat, 25 Aug 2018 12:14:33 GMT, Vitalii Minnakhmetov wrote:
I use http://vibed.org/docs#web the Web Framework as a starting point.
I need to output some html directly into the diet templated page.
Is there a way of doing so?
I found there are some special objects I can pass to render!() but I couldn't find anything that helps in my case. Would writing custom @dietTraits thing help me or do I have to refer to diet API and then post the rendered page via lower level vibe api?
Or is there any other common way to process some html parts of the page yourself?
From within the Diet template, there are three ways to handle raw HTML:
Static inline-HTML can be embedded directly as static text in the template (e.g.
| This is <strong>bold</strong>.
)strings or input ranges of
char
can be output using the raw modifier:div!= generateSomeHTML()
ordiv embedded: !{generateSomeHTML()}
There is a special variable
_diet_output
available within the template, which is an output range that makes it possible to write directly to the destination:- _diet_output.put("<p>This is HTML</p>");
*
Any data necessary can simply be passed as variables through template arguments to the render!()
call.
* The name is defined by diet.defs.dietOutputRangeName
- using mixin(dietOutputRangeName)
instead of _diet_output
directly is recommended, as that ensures full forward compatibility in the case that this name should ever be changed.