Lasso Soft Inc. > Home

[css_normalizeurls]

Linkcss_normalizeurls
AuthorJason Huck
CategoryFile
Version8.5.x
LicensePublic Domain
Posted22 Sep 2008
Updated22 Sep 2008
More by this author...

Description

Returns a version of the given CSS file with all relative URLs converted to absolute ones. Requires [url_normalize].

Sample Usage

var('newcss') = css_normalizeurls('/path/to/file.css');

Source Code

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;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft