Skip to content

Commit

Permalink
fix bug: #30; add tag for play-rythm template engine
Browse files Browse the repository at this point in the history
  • Loading branch information
greenlaw110 committed Feb 10, 2012
1 parent bf1622b commit d8a9883
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 72 deletions.
Binary file modified java/core/lib/play-greenscript.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions java/play/app/views/tags/rythm/greenscript/closeTag_.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@args String type;
@if ("js".equalsIgnoreCase(type)) </script> @ else if ("css".equalsIgnoreCase(type)) </style> @
#{verbatim}
@args String type
@("js".equalsIgnoreCase(type) ? "</script>" : ("css".equalsIgnoreCase(type) ? "</style>" : "" ))
#{/verbatim}
12 changes: 3 additions & 9 deletions java/play/app/views/tags/rythm/greenscript/css.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#{verbatim}
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, int priority;

@{
if (null == nameList) nameList = _getAs("arg", String.class);
String cacheKey = nameList + output + all + deps + media + browser + id + charset + priority;
}@

@cacheOnProd(cacheKey, "1h") <<
@greenscript.gs_(nameList = nameList, output = output, all = all, deps = deps, media = media, browser = browser, id = id, charset = charset, priority = priority, type = "css")
@
@greenscript.gs_(nameList = nameList, output = output, all = all, deps = deps, media = media, browser = browser, id = id, charset = charset, priority = priority, type = "css", _body = _body)
#{/verbatim}
82 changes: 41 additions & 41 deletions java/play/app/views/tags/rythm/greenscript/gs_.html
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
@import play.modules.greenscript.GreenScriptPlugin;
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, int priority = 0, String type;
@{
final com.greenscriptool.RenderSession sm = (com.greenscriptool.RenderSession)GreenScriptPlugin.session(type);
if (null != nameList) {
sm.declare(nameList, media, browser);
}
_logger.info("aaa");

all = all || "all".equals(output);
deps = deps || "deps".equals(output);
#{verbatim}
@import play.modules.greenscript.GreenScriptPlugin
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, int priority = 0, String type
@{
final com.greenscriptool.RenderSession sm = (com.greenscriptool.RenderSession)GreenScriptPlugin.session(type);
if (null != nameList) {
sm.declare(nameList, media, browser);
}

boolean _output = all || deps || ((null != output) && ((output instanceof Boolean) ? (Boolean)output : !"false".equals(output.toString())));
}@
all = all || "all".equals(output);
deps = deps || "deps".equals(output);

@if (_output)
@if (all)
@// default browser with default media
@greenscript.output_(nameList, deps = deps, all = all, media = null, browser = null, id = id, charset = charset, type = type, sm = sm)
boolean _output = all || deps || ((null != output) && ((output instanceof Boolean) ? (Boolean)output : !"false".equals(output.toString())));
}@

@// default browser with non-default media
@each String med: sm.getMedias(null)
@greenscript.output_(nameList, deps = deps, all = all, media = med, browser = null, id = id, charset = charset, type = type, sm = sm)
@
@if (_output) {
@if (all) {
@// default browser with default media
@greenscript.output_(nameList, deps = deps, all = all, media = null, browser = null, id = id, charset = charset, type = type, sm = sm)

@// non-default browsers
@each String bro: sm.getBrowsers()
@each String med: sm.getMedias(bro)
@greenscript.output_(nameList, deps = deps, all = all, media = med, browser = bro, id = id, charset = charset, type = type, sm = sm)
@
@
@ else
@greenscript.output_(nameList, deps = deps, all = all, media = media, browser = browser, id = id, charset = charset, type = type, sm = sm)
@
@
@// default browser with non-default media
@each String med: sm.getMedias(null) {
@greenscript.output_(nameList, deps = deps, all = all, media = med, browser = null, id = id, charset = charset, type = type, sm = sm)
}

@// handle inline code
@// non-default browsers
@each String bro: sm.getBrowsers() {
@each String med: sm.getMedias(bro) {
@greenscript.output_(nameList, deps = deps, all = all, media = med, browser = bro, id = id, charset = charset, type = type, sm = sm)
}
}
} else {
@greenscript.output_(nameList, deps = deps, all = all, media = media, browser = browser, id = id, charset = charset, type = type, sm = sm)
}
}

@if (null != _body)
@if (_output)
@greenscript.openTag_(type)
@_body
@greenscript.closeTag_(type)
@ else
@{ sm.declareInline(_body.toString(), priority); }@
@
@
@// handle inline code
@if (null != _body) {
@if (_output) {
@greenscript.openTag_(type)
@_body
@greenscript.closeTag_(type)
} else {
@{ sm.declareInline(_body.toString(), priority) }@
}
}
#{/verbatim}
7 changes: 4 additions & 3 deletions java/play/app/views/tags/rythm/greenscript/importCss.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import play.modules.greenscript.GreenScriptPlugin;
#{verbatim}
@import play.modules.greenscript.GreenScriptPlugin
@args String nameList;

@GreenScriptPlugin.lessImport(nameList)
@GreenScriptPlugin.lessImport(nameList)
#{/verbatim}
14 changes: 4 additions & 10 deletions java/play/app/views/tags/rythm/greenscript/js.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, int priority;

@{
if (null == nameList) nameList = _getAs("arg", String.class);
String cacheKey = nameList + output + all + deps + media + browser + id + charset + priority;
}@

@cacheOnProd(cacheKey, "1h") <<
@greenscript.gs_(nameList = nameList, output = output, all = all, deps = deps, media = media, browser = browser, id = id, charset = charset, priority = priority, type = "js")
@
#{verbatim}
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, int priority
@greenscript.gs_(nameList = nameList, output = output, all = all, deps = deps, media = media, browser = browser, id = id, charset = charset, priority = priority, type = "js", _body = _body)
#{/verbatim}
9 changes: 3 additions & 6 deletions java/play/app/views/tags/rythm/greenscript/openTag_.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#{verbatim}
@args String type

@if ("js".equalsIgnoreCase(type))
<script type="text/javascript">
@ else if ("css".equalsIgnoreCase(type))
<style type="text/css">
@
@("js".equalsIgnoreCase(type) ? "<script type=\"text/javascript\">" : ("css".equalsIgnoreCase(type) ? "<style type=\"text/css\">" : "" ))
#{/verbatim}
2 changes: 1 addition & 1 deletion java/play/app/views/tags/rythm/greenscript/output_.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

@{ String inline = all ? sm.outputInline().trim() : null; }@
@if (null != inline && !"".equals(inline))
@greenscript.openTag_(type) @inline.raw() @greenscript.closeTag_(type)
@greenscript.openTag_(type) @inline @greenscript.closeTag_(type)
@

0 comments on commit d8a9883

Please sign in to comment.