Giter VIP home page Giter VIP logo

jfinal-assets's Introduction

说明

JFinal框架结合jsp、beetl、freemarker模版的js、css在线合并压缩插件!

结合CDN使用效果更佳哦

依赖

  1. JFinal

  2. yuicompressor

  3. commons-io

使用

<dependency>
    <groupId>net.dreamlu</groupId>
    <artifactId>JFinal-assets</artifactId>
    <version>1.0.0</version>
</dependency>

###Beetl中使用 ###自定义标签

##自定义标签
TAG.assets = net.dreamlu.ui.beetl.AssetsTag

###js

<#assets file="/assets/assets.jjs"; src>
    <script src="${ctxPath}${src}"></script>
</#assets>

###css

<#assets file="/assets/assets.jcss"; href>
    <link rel="stylesheet" href="${ctxPath}${href}">
</#assets>

file: 需要压缩的js、css列表

assets.jjs示例:

#开头表注释
/js/jquery.min.js
/js/jquery-ui.min.js
/js/modernizr.min.js
/js/superfish.min.js
/js/application.js

###JSP中使用

首先、导入标签库

<%@ taglib prefix="assets" uri="http://www.dreamlu.net/tags/assets.tld" %>

同理如beetl

<assets:assets var="x" file="/assets/assets.jjs">
	<script src="${x}" type="text/javascript" ></script>
</assets:assets>

###freemarker中使用

首先、配置(可在JFinal的config中完成)

FreeMarkerRender.getConfiguration().setSharedVariable("assets", new AssetsDirective());

同理如beetl

<@assets var="x" file="/assets/assets.jjs">
	<script src="${x}" type="text/javascript" ></script>
</@assets>

文章

对css,js压缩之combo以及七牛cdn的思考:http://blog.dreamlu.net/blog/47

更新说明

2015-12-30 v0.0.3

  1. 升级到JFinal2.1,JFinal低版本用户请使用v0.0.3

交流群

如梦技术:237587118

捐助共勉

微信捐助

微信捐助

支付宝捐助

QQ捐助

QQ捐助

License

( The MIT License )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.