[yui_compress]

Description

Link: [yui_compress]
Author: Jason Huck
Category: Utility
Version: 8.5.x
License: Public Domain
Posted: Sep. 22, 2008
Updated: Jan. 01, 0001
More by this author...

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.

Parameters

-source string, required Path to the source JS or CSS file.
-target string, optional Where the resulting file should be written.
-yuipath string, optional System path to yuicompressor.jar.

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net