Conditional inclusion of HTML content in the plugin's template file
-
{{{ if your_condition }}} <span>HTML stuff you only want displayed under 'condition'</span> {{{ end }}}
Then you have to set
your_condition
as a property of the data object when callingres.render
:res.render('template', { your_condition: req.path === 'targetted_path', });
Just as example, might not actually work.
-
//map.tpl
<ul class="nav nav-pills">
<li><a href="{config.relative_path}/map?section=section1">[[map:A]]</a></li>
<li><a href="{config.relative_path}/map?section=section2">[[map:B]]</a></li>
</ul>{{{ if my_condition }}}
<span>
<p>Some Text</p>
<input type="text" class="form-control input-lg" placeholder="Search"/>
</span>
{{{ end }}}//In the plugin's controllers.js
console.log(nconf.get('relative_path')); //returns undefined
console.log(req.path); //returns /api/mapIn fact I was expecting req.path should equal to http://localhost:4567/map?section=A
.. but it is returning req.path equal to /api/mapThank you very much
-
//map.tpl
<ul class="nav nav-pills">
<li><a href="{config.relative_path}/map?section=section1">[[map:A]]</a></li>
<li><a href="{config.relative_path}/map?section=section2">[[map:B]]</a></li>
</ul>{{{ if my_condition }}}
<span>
<p>Some Text</p>
<input type="text" class="form-control input-lg" placeholder="Search"/>
</span>
{{{ end }}}//In the plugin's controllers.js
console.log(nconf.get('relative_path')); //returns undefined
console.log(req.path); //returns /api/mapIn fact I was expecting req.path should equal to http://localhost:4567/map?section=A
.. but it is returning req.path equal to /api/map -
Oh actually in that case you should be able to use
req.query.section
I think.