* Allow subskins of the currently rendered skin to be rendered using
relative skin names ("#subskinName") * Fix minor bug in subskin parsing.
This commit is contained in:
parent
4531ef6e4b
commit
3e20cadca1
3 changed files with 34 additions and 2 deletions
|
@ -113,6 +113,9 @@ public final class ResponseTrans extends Writer implements Serializable {
|
|||
// the message digest used to generate composed digests for ETag headers
|
||||
private transient MessageDigest digest;
|
||||
|
||||
// the skin current or last rendered skin
|
||||
private transient volatile Skin activeSkin;
|
||||
|
||||
// the application
|
||||
Application app;
|
||||
|
||||
|
@ -823,6 +826,25 @@ public final class ResponseTrans extends Writer implements Serializable {
|
|||
skincache.put(id, skin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the skin currently being rendered, returning the previously active skin.
|
||||
* @param skin the new active skin
|
||||
* @return the previously active skin
|
||||
*/
|
||||
public Skin switchActiveSkin(Skin skin) {
|
||||
Skin previousSkin = activeSkin;
|
||||
activeSkin = skin;
|
||||
return previousSkin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the skin currently being rendered, or none.
|
||||
* @return the currently active skin
|
||||
*/
|
||||
public Skin getActiveSkin() {
|
||||
return activeSkin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a cookie.
|
||||
*
|
||||
|
|
|
@ -256,6 +256,7 @@ public final class Skin {
|
|||
// register param object, remember previous one to reset afterwards
|
||||
Map handlers = res.getMacroHandlers();
|
||||
Object previousParam = handlers.put("param", paramObject);
|
||||
Skin previousSkin = res.switchActiveSkin(parentSkin);
|
||||
|
||||
try {
|
||||
int written = offset;
|
||||
|
@ -279,6 +280,7 @@ public final class Skin {
|
|||
}
|
||||
} finally {
|
||||
reval.skinDepth--;
|
||||
res.switchActiveSkin(previousSkin);
|
||||
if (previousParam == null) {
|
||||
handlers.remove("param");
|
||||
} else {
|
||||
|
@ -422,6 +424,7 @@ public final class Skin {
|
|||
}
|
||||
b.append(source[i]);
|
||||
escape = false;
|
||||
break;
|
||||
|
||||
case '|':
|
||||
|
||||
|
|
|
@ -596,10 +596,17 @@ public class RhinoEngine implements ScriptingEngine {
|
|||
* caching.
|
||||
*/
|
||||
public Skin getSkin(String protoName, String skinName) throws IOException {
|
||||
SkinKey key = new SkinKey(protoName, skinName);
|
||||
Skin skin;
|
||||
ResponseTrans res = getResponse();
|
||||
if (skinName.startsWith("#")) {
|
||||
// evaluate relative subskin name against currently rendering skin
|
||||
skin = res.getActiveSkin();
|
||||
return skin == null ?
|
||||
null : skin.getSubskin(skinName.substring(1));
|
||||
}
|
||||
|
||||
Skin skin = res.getCachedSkin(key);
|
||||
SkinKey key = new SkinKey(protoName, skinName);
|
||||
skin = res.getCachedSkin(key);
|
||||
|
||||
if (skin == null) {
|
||||
// retrieve res.skinpath, an array of objects that tell us where to look for skins
|
||||
|
|
Loading…
Add table
Reference in a new issue