Javascript load depending on presenter
- coyot_
- Member | 12
I feel dumb. :-) Thank you.
Still, is there any more elegant solution? Previously, I worked with Zend and there was possibility to write it to config file something like this:
scripts.gallery = "js/gallery.js"
But if there is nothing like it, I'm perfectly ok with the suggested way.
- Marek Šneberger
- Member | 130
I'm using in @layout.latte block ‘scripts’ for load default scripts:
@layout.latte:
{#scripts}
<script src="{$basePath}/js/jquery.min.js"></script>
and more...
{/#}
And for view that need default and extended scripts (eg. Gallery/default)
{#scripts}
{#include parent} //load default scrips
<script type="text/javascript" src="{$basePath}/assets/js/gallery.js"></script>
{/#}
- coyot_
- Member | 12
Marek: This is quite elegant solution. Thank you very much! :-)
Edit: I found out, you propably have syntax error in your example. It seems, that you can't use e.g.{#scripts}, but {block #scripts}, etc.
My solution (inspired by yours):
@layout.latte
{block #scripts}
<script src="{$basePath}/js/jquery.min.js"></script>
...
{/block}
And for view that need default and extended scripts (eg. Gallery/default)
{block #scripts}
{include #parent}
<script type="text/javascript" src="{$basePath}/assets/js/gallery.js"></script>
{/block}
Last edited by coyot_ (2013-11-14 13:05)