Bug fixes

This commit is contained in:
Ziver Koc 2015-04-25 15:22:23 +00:00
parent 909ad1db7c
commit a06debdae3

View file

@ -244,8 +244,6 @@ public class Templator {
public void compile(StringBuilder str) { public void compile(StringBuilder str) {
Object obj = attrib.getObject(); Object obj = attrib.getObject();
if(obj != null) { if(obj != null) {
Object prevObj = get(".");
set(".", obj);
if(obj instanceof Boolean){ if(obj instanceof Boolean){
if ((Boolean) obj) if ((Boolean) obj)
@ -255,21 +253,22 @@ public class Templator {
if ((Integer) obj != 0) if ((Integer) obj != 0)
super.compile(str); super.compile(str);
} }
else if(obj instanceof Iterable){ else if(obj instanceof Iterable || obj.getClass().isArray()) {
Object prevObj = get(".");
set(".", obj);
if (obj instanceof Iterable) {
for (Object o : (Iterable) obj) { // Iterate through the whole list for (Object o : (Iterable) obj) { // Iterate through the whole list
set(".", o); set(".", o);
super.compile(str); super.compile(str);
} }
} } else if (obj.getClass().isArray()) {
else if (obj.getClass().isArray()) {
int length = Array.getLength(obj); int length = Array.getLength(obj);
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
set(".", Array.get(obj, i)); set(".", Array.get(obj, i));
super.compile(str); super.compile(str);
} }
} }
else
super.compile(str);
// Reset map to parent object // Reset map to parent object
if(prevObj != null) if(prevObj != null)
@ -277,6 +276,10 @@ public class Templator {
else else
remove("."); remove(".");
} }
else
super.compile(str);
}
} }
} }