Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Will Smarty version 3 support use of tags in css and javascr

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Lloyd
Smarty n00b


Joined: 04 Nov 2009
Posts: 1

PostPosted: Wed Nov 04, 2009 12:54 am    Post subject: Will Smarty version 3 support use of tags in css and javascr Reply with quote

Hi

Will Smarty version 3 support use of tags in a external css and javascript file, which is then icluded in the header portion of my template. An example is when I have a tag {images_dir} which is set to the location of the images used in my templates.

In css I would like to use this tag as follows:

body {
background-image: url ({images_dir}background.png) ;
}


I hope I have explained my question properly.

Thank you,



Lloyd
Back to top
View user's profile Send private message
schildi
Smarty Regular


Joined: 11 Mar 2005
Posts: 81

PostPosted: Wed Nov 04, 2009 7:10 am    Post subject: hi Reply with quote

why dont you put all your file-path-related css-definitions in a
Code:
<style type="text/css">[...]</style>

and put that into an extra template that you include in your header template?

i do it like that.

in smarty 2.x you just have to enclose the style-definitions with a {literal}{/literal} smarty-tag. and do it the other way round for the template-vars you want to use. thats it.

example [header_css.tpl]:

Code:
<style type="text/css">
{literal}
body {
background-image: url ({/literal}{$images_dir}{literal}background.png) ;
}
{/literal}
</style>


in smarty 3.x you even can omit that {literal}-tag, if you have at least 1 space between a "{" and the following code
Back to top
View user's profile Send private message Send e-mail
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Nov 04, 2009 5:00 pm    Post subject: Reply with quote

This would be simpler than literal if you need smarty tags within:

Code:
<style type="text/css">
body {ldelim}
background-image: url ({$images_dir}background.png) ;
{rdelim}

</style>


and with Smarty 3, no literal escapement required.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP