simple-html-template icon indicating copy to clipboard operation
simple-html-template copied to clipboard

Add parameters to your includes

Open Zenoo opened this issue 7 years ago • 9 comments

I started using simple-html-template recently, it's great. However, it would be even greater if you could pass some parameters to your includes.

Example

index.html

...
<include src="partial/breadcrumb.html" title="Home" />
...

partial/breadcrumb.html

...
<variable name="title" />
...

This would result to Home being displayed inside the breadcrumb partial template.

Zenoo avatar Dec 20 '18 10:12 Zenoo

Interesting. Since I'm beginner in node.js , could you add properly into code the fixes I mentioned in my published issues? I know they are very simple for experienced programmers in this area. I just do not want to make stupid mistakes. Please take a look what I published long time ago in the Issues section.

I tried to contact with the author, but he doesn't care...

xdon82 avatar Dec 21 '18 08:12 xdon82

@xdon82 I see no real need to add support for PHP files, since you can already use include in PHP natively. I also can't reproduce your other issue about the Windows platform.

Zenoo avatar Dec 21 '18 08:12 Zenoo

I mix php with html in some files. So If php code is included in html where the header (including menu) is repetive, then it will be changed automatically when I change that included part - body-header.html for instance. If you have better idea how to do it, please show me an example

xdon82 avatar Dec 21 '18 09:12 xdon82

or rather i was supposed to say when html is included in php , but the idea is the same...

xdon82 avatar Dec 21 '18 09:12 xdon82

Use <?php include ('body-header.html'); ?> instead of <include src="body-header.html"/> in your PHP files.

See the official PHP documentation

Zenoo avatar Dec 21 '18 09:12 Zenoo

hmm tbh you are right, I don't know why I made it much more complicated :P I think i wanted to keep it in one way (the template system) but as you noticed it doesn;t make sense

thx

xdon82 avatar Dec 21 '18 09:12 xdon82

btw should the code be triggered automatically on partial file change ? It doesn't work for me

xdon82 avatar Dec 21 '18 09:12 xdon82

@xdon82 This is only a feature request, it's not working yet.

Zenoo avatar Dec 21 '18 09:12 Zenoo

Thank you guys for the suggestion. Please feel free to create PRs, I am quite busy at work right now, I will take a look when I have the capacity. Thanks!

phonglk avatar Dec 23 '18 13:12 phonglk