posthtml / posthtml-expressions

Use variables, JS-like expressions, and even markup-powered logic in your HTML.
Other
123 stars 20 forks source link

[feat]: A way to define data in html #54

Open andreyvolokitin opened 6 years ago

andreyvolokitin commented 6 years ago

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?

Scrum commented 6 years ago

@andreyvolokitin Hi, see example

andreyvolokitin commented 6 years ago

Which example specifically? I can only find one here where it says that we need to pass data directly to the plugin

Scrum commented 6 years ago

Currently only the plug-in is available. Perhaps it will help you scopes

Scrum commented 6 years ago

related to #44 (date as inline in scope)

andreyvolokitin commented 6 years ago

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

andreyvolokitin commented 6 years ago

Possible implementation:

<scope
    var1="text"
    var2="text text text"
    var3="text text text text text"
>
   <include src="include.html"></include>
</scope>

also:

Problems:

What do you think?

andreyvolokitin commented 6 years ago

cc @jescalan @voischev @awinogradov @michael-ciniawsky @mrmlnc

gregorybolkenstijn commented 5 years ago

+1

chrisfwd commented 4 years ago

+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.

Scrum commented 4 years ago

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.