posthtml-expressions icon indicating copy to clipboard operation
posthtml-expressions copied to clipboard

[feat]: A way to define data in html

Open andreyvolokitin opened this issue 7 years ago • 10 comments

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 avatar Dec 31 '17 19:12 andreyvolokitin

@andreyvolokitin Hi, see example

Scrum avatar Jan 05 '18 19:01 Scrum

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

andreyvolokitin avatar Jan 07 '18 12:01 andreyvolokitin

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

Scrum avatar Jan 12 '18 07:01 Scrum

related to #44 (date as inline in scope)

Scrum avatar Jan 12 '18 07:01 Scrum

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 avatar Jan 12 '18 08:01 andreyvolokitin

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?

andreyvolokitin avatar Jan 13 '18 18:01 andreyvolokitin

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

andreyvolokitin avatar Jan 15 '18 23:01 andreyvolokitin

+1

gregorybolkenstijn avatar Aug 28 '18 12:08 gregorybolkenstijn

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

chrisfwd avatar Nov 13 '19 14:11 chrisfwd

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.

Scrum avatar Nov 13 '19 14:11 Scrum