posthtml-expressions
posthtml-expressions copied to clipboard
[feat]: A way to define data in html
Documentation states one way to define data — via plugin invocation. But often it may be necessary to define data directly in HTML for specific expressions (like data for included "template" with some expressions). May it be possible with posthtml-expressions
?
@andreyvolokitin Hi, see example
Which example specifically? I can only find one here where it says that we need to pass data directly to the plugin
Currently only the plug-in is available. Perhaps it will help you scopes
related to #44 (date as inline in scope)
Yep, seen that. What I wanted is something like this: https://mozilla.github.io/nunjucks/templating.html#macro — a standard concept in templating engines, where you invoke some partial with some parameters. It is interesting to mention that locals
do not seem like locals at all, but more like globals, but I understand that purpose of that plugin is maybe different from what I wanted
Possible implementation:
<scope
var1="text"
var2="text text text"
var3="text text text text text"
>
<include src="include.html"></include>
</scope>
also:
- make
with
optional - overwrite intersected properties from
with
in case it present
Problems:
- strange syntax
-
with
becomes a "reserved" word and can not be used as expression variable - will attributes strings be sufficient to hold values instead of real JS values used in
locals
object?
What do you think?
cc @jescalan @voischev @awinogradov @michael-ciniawsky @mrmlnc
+1
+1 Any plan to implement inline invocation of templates like stated above? We're using rollup for our build process and, to use this, it seems like I'd need to either add locals to my build code (not feasible) or in my template HTML file (also not feasible) in order to use this. It would be really nice to be able to define an object in my JS and invoke the template and pass in the JS object similar to how rollup-plugin-posthtml-template works, but better.
interest in this task seems to be growing) I will try to increase the priority of this task for myself.
Anyone can make their contribution to the development of this project.