Link | css_normalizeurls |
Author | Jason Huck |
Category | File |
Version | 8.5.x |
License | Public Domain |
Posted | 22 Sep 2008 |
Updated | 22 Sep 2008 |
More by this author... |
Returns a version of the given CSS file with all relative URLs converted to absolute ones. Requires [url_normalize].
var('newcss') = css_normalizeurls('/path/to/file.css');
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag( 'normalizeurls', -namespace='css_', -req='in', -priority='replace', -encodenone, -description='Returns a version of the given CSS file with all relative URLs converted to absolute ones.' ); fail_if(!#in->endswith('.css'), -1, 'File does not have a .css extension.'); local('file') = string(include_raw(#in)); local('base') = string(#in)->removetrailing(#in->split('/')->last)&; local('regex') = regexp('url\\([\'"]?(?!/|http)(.+)?[\'"]?\\)', -input=#file); while(#regex->find); local('replacement') = 'url(' + url_normalize(#regex->matchstring(1), #base) + ')'; #regex->appendreplacement(#replacement); /while; #regex->appendtail; return(#regex->output); /define_tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft