Lasso Soft Inc. > Home

[yui_compress]

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

Description

This tag is a wrapper for the YUI Compressor, a Java package that minifies (optimizes and compresses) JavaScript and CSS files. The tag requires the YUI Compressor, [os_process], and the [shell] tag.

Accepts a source file path, a target file path, and the path to the yuicompressor.jar file as inputs. If no target is specified, the tag returns the output to Lasso instead of writing to disk.

Sample Usage

yui_compress(
    -source='/path/to/big.js', 
    -target='/path/to/small.js',
    -yuipath='///system/path/to/yuicompressor.jar'
);

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(
	'compress',
	-namespace='yui_',
	-req='source', -type='string',
	-opt='target', -type='string',
	-opt='yuipath', -type='string',
	-priority='replace',
	-encodenone,
	-description='Compresses the specified file using the YUI Compressor.'
);
	// path to YUI Compressor
	if(!local_defined('yuipath'));
		if(var_defined('__amOptions'));
			local('yuipath') = $__amOptions->find('paths')->find('yui');
		else;
			local('yuipath') = server_webroot + '/lib/tools/yuicompressor.jar';
		/if;
	/if;

	local('cmd') = 'java -jar ' + #yuipath + ' ' + #source;
	local_defined('target') ? #cmd += ' -o ' + #target;	
	local('out') = shell('java -jar ' + #yuipath + ' ' + #source);

	return(#out);
/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