In the file main.html
, in default project created by Play!, there's this line :
#{get 'moreStyles' /}
I understand that if I need to add more styles, in my view script, I have to use
#{set tag:'value' /}
where tag
should be moreStyles
, but it seems worng to set the value to the full HTML <link>
tag. And what happens if the view needs to add more styles, or scripts?
Thanks!
you set more styles with:
#{set 'moreStyles'}
#{stylesheet 'main.css' /}
#{/set}
like scripts:
#{set 'moreScripts'}
#{script 'base64.js'/}
#{/set}
simply using the #{set} tag will overwrite the previous values.
that is if you issue
#{set 'moreStyles'}xxx#{/set}
and then
#{set 'moreStyles'}yyy#{/set}
then
#{get 'moreStyles' /}
will only return yyy
in order to achieve what you want you have to
#{set 'moreStyles'}
#{get 'moreStyles' /}
#{stylesheet 'main.css' /}
#{/set}
and then the stylesheet main.css will be added to the previous value of morestyles
On a similar situation I ended up creating my own #{addStyle} tag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With