public
Description: E4X-based template engine
Home | Edit | New

Extension Library

CSS and script shortcuts

The following are useful to keep paths for scripts and CSS all in one place. Example:


    <st:script src="jquery.js"/>

Becomes:


    <script type="text/javascript" src="/myapp/static/scripts/jquery.js"> </script>

Code:


    seethrough.processors['http://hyperstruct.net/seethrough#js::css'] = 
        function(attrValue) {
        return function stScript(element, env, children) {
            var cssPath = '/myapp/static/style/' + element.@href;
            return <link rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml" 
                href={cssPath} type="text/css"/>;
        }
    };
    
    seethrough.processors['http://hyperstruct.net/seethrough#js::script'] = 
        function(attrValue) {
        return function stScript(element, env, children) {
            var scriptPath = '/mypapp/static/scripts/' + element.@src;
            return <script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"
                src={scriptPath}> </script>;
        }
    };

Please note: the above will make designers unable to work on templates independently of the application.

Last edited by bard, Sun Sep 21 04:48:21 -0700 2008
Home | Edit | New
Versions: