Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andreyvolokitin opened this issue Dec 31, 2017 · 10 comments
Open

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

andreyvolokitin opened this issue Dec 31, 2017 · 10 comments
Assignees
Labels
Milestone

Comments

@andreyvolokitin
Copy link

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
Copy link
Member

Scrum commented Jan 5, 2018

@andreyvolokitin Hi, see example

@Scrum Scrum self-assigned this Jan 5, 2018
@andreyvolokitin
Copy link
Author

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

@Scrum
Copy link
Member

Scrum commented Jan 12, 2018

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

@Scrum Scrum changed the title A way to define data in html [feat]: A way to define data in html Jan 12, 2018
@Scrum Scrum added this to the v1.2.0 milestone Jan 12, 2018
@Scrum Scrum added the feature label Jan 12, 2018
@Scrum
Copy link
Member

Scrum commented Jan 12, 2018

related to #44 (date as inline in scope)

@andreyvolokitin
Copy link
Author

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
Copy link
Author

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
Copy link
Author

andreyvolokitin added a commit to andreyvolokitin/posthtml-expressions that referenced this issue Jan 29, 2018
andreyvolokitin added a commit to andreyvolokitin/posthtml-expressions that referenced this issue Feb 4, 2018
@gregorybolkenstijn
Copy link

+1

@chrisfwd
Copy link

+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
Copy link
Member

Scrum commented Nov 13, 2019

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 Scrum modified the milestones: v1.2.0, 1.5.0 May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants