com.googlecode.webutilities.tags
Class YUIMinTag
java.lang.Object
javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.tagext.BodyTagSupport
com.googlecode.webutilities.tags.YUIMinTag
- All Implemented Interfaces:
- Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag
public class YUIMinTag
- extends javax.servlet.jsp.tagext.BodyTagSupport
The YUIMinTag is the JSP custom tag to expose the YUICompressor functionality in the JSP.
Using the YUIMinTag inline css, js, json can be compressed.
Usage
Put the webutilities-x.y.z.jar and yuicompressor-x.y.z.jar (See dependency mentioned below) in your classpath (WEB-INF/lib folder of your webapp).
Declare the taglib and prefix in your JSP
<%@ taglib uri="http://webutilities.googlecode.com/taglib/yuimin" prefix="ymin" %>
Use the tag to minify your inline JavaScript
<ymin:minify type="js">
...
// your inline uncompressed JavaScript
...
</ymin:minify>
You can also similarly use the tag to minify your inline style
<ymin:minify type="css">
...
// your inline uncompressed CSS
...
</ymin:minify>
Attributes
The YUIMinTag also supports the different attributes similar to YUICompressor's command line options. Below are the attributes and their explanations.
all attrinutes are optional except type.
type - possible values are js or css. The only required attribute. Usage as shown above.
lineBreak - equivalent to YUICompressor --line-break. Insert a line break after the specified column number
noMunge - equivalent to YUICompressor --nomunge. Minify only, do not obfuscate.
preserveSemi - equivalent to YUICompressor --preserve-semi. Preserve all semicolons.
disableOptimizations - equivalent to YUICompressor --disable-optimizations. Disable all micro optimizations.
Dependency
The YUIMinTag depends on jsp-api and YUICompressor jar to be in the classpath.
jsp-api.jar - Must be already present in your webapp classpath
yuicompressor-x.y.z.jar - Download and put appropriate version of this jar in your classpath (in WEB-INF/lib)
Visit http://code.google.com/p/webutilities/wiki/YUIMinTag for more details.
- Version:
- 1.0
- Author:
- rpatil
- See Also:
- Serialized Form
| Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport |
bodyContent |
| Fields inherited from class javax.servlet.jsp.tagext.TagSupport |
id, pageContext |
| Fields inherited from interface javax.servlet.jsp.tagext.BodyTag |
EVAL_BODY_BUFFERED, EVAL_BODY_TAG |
| Fields inherited from interface javax.servlet.jsp.tagext.IterationTag |
EVAL_BODY_AGAIN |
| Fields inherited from interface javax.servlet.jsp.tagext.Tag |
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
| Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport |
doEndTag, doInitBody, doStartTag, getBodyContent, getPreviousOut, release, setBodyContent |
| Methods inherited from class javax.servlet.jsp.tagext.TagSupport |
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.jsp.tagext.Tag |
getParent, setPageContext, setParent |
YUIMinTag
public YUIMinTag()
setType
public void setType(String type)
setCharset
public void setCharset(String charset)
setLineBreak
public void setLineBreak(int lineBreak)
setNoMunge
public void setNoMunge(boolean noMunge)
setPreserveSemi
public void setPreserveSemi(boolean preserveSemi)
setDisableOptimizations
public void setDisableOptimizations(boolean disableOptimizations)
doAfterBody
public int doAfterBody()
throws javax.servlet.jsp.JspException
- Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag- Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
- Throws:
javax.servlet.jsp.JspException
Copyright © 2011. All Rights Reserved.