Skip to content

Commit

Permalink
fixed alias of 'size' and 'length'
Browse files Browse the repository at this point in the history
  • Loading branch information
synapticloop committed Feb 6, 2017
1 parent e91bccc commit 5669a4f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,19 @@ repositories {

```
dependencies {
runtime(group: 'synapticloop', name: 'templar', version: '1.4.0', ext: 'jar')
runtime(group: 'synapticloop', name: 'templar', version: '1.4.1', ext: 'jar')
compile(group: 'synapticloop', name: 'templar', version: '1.4.0', ext: 'jar')
compile(group: 'synapticloop', name: 'templar', version: '1.4.1', ext: 'jar')
}
```

or, more simply for versions of gradle greater than 2.1

```
dependencies {
runtime 'synapticloop:templar:1.4.0'
runtime 'synapticloop:templar:1.4.1'
compile 'synapticloop:templar:1.4.0'
compile 'synapticloop:templar:1.4.1'
}
```

Expand All @@ -238,7 +238,7 @@ dependencies {
<dependency>
<groupId>synapticloop</groupId>
<artifactId>templar</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
<type>jar</type>
</dependency>
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {
group = 'synapticloop'
archivesBaseName = 'templar'
description = """Templar templating engine"""
version = '1.4.0'
version = '1.4.1'

sourceCompatibility = 1.7
targetCompatibility = 1.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public abstract class CommandLineToken {

public CommandLineToken(StringTokenizer stringTokenizer) throws ParseException {}

/**
* Evaluate the token
*
* @param templarContext The templar context for any lookups that are required
*
* @return The evaluated object
*
* @throws RenderException If there was an error evaluating the command line
*/
public abstract Object evaluate(TemplarContext templarContext) throws RenderException;

@Override
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/synapticloop/templar/utils/TemplarContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public class TemplarContext {
functionAliasMap.put("lt", "<");
functionAliasMap.put("lte", "<=");

functionAliasMap.put("length", "size");
functionAliasMap.put("size", "length");

}

Expand Down Expand Up @@ -277,7 +277,7 @@ private String getRegisteredFunctions() {
* @return the return of the invoked function
*
* @throws FunctionException if there was a problem invoking the function, or
* no function was registsred with that name
* no function was registered with that name
*/
public Object invokeFunction(String name, Object[] args, TemplarContext templarContext) throws FunctionException {
if(null == args) {
Expand All @@ -301,6 +301,14 @@ public Object invokeFunction(String name, Object[] args, TemplarContext templarC
}
}

/**
* Return the base function, which will also look up the aliase map for any
* function that has more that one way of being referenced.
*
* @param name The name of the function to look up
*
* @return The name of the function that was looked up
*/
public static String getBaseFunction(String name) {
if(functionAliasMap.containsKey(name)) {
return(functionAliasMap.get(name));
Expand Down

0 comments on commit 5669a4f

Please sign in to comment.