Skip to content

Commit

Permalink
Supporting dynamic property getter in the template engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Apr 18, 2016
1 parent a9c723c commit 42ccf89
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
32 changes: 32 additions & 0 deletions rapidoid-commons/src/main/java/org/rapidoid/render/Getter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.rapidoid.render;

/*
* #%L
* rapidoid-commons
* %%
* Copyright (C) 2014 - 2016 Nikolche Mihajlovski and contributors
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/

import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;

@Authors("Nikolche Mihajlovski")
@Since("5.1.0")
public interface Getter {

Object get(String name);

}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ private static Object propOf(String name, Object[] scope) {
return map.get(name);
}

} else if (x instanceof Getter) {
Getter getter = (Getter) x;

return getter.get(name);

} else {
Prop prop = Beany.property(x, name, false);

Expand Down
1 change: 1 addition & 0 deletions rapidoid-commons/src/main/resources/rapidoid-classes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ org.rapidoid.pool.SynchronizedArrayPool
org.rapidoid.pool.SynchronizedPool
org.rapidoid.pool.ThreadSafeArrayPool
org.rapidoid.RapidoidThing
org.rapidoid.render.Getter
org.rapidoid.render.RapidoidTemplate
org.rapidoid.render.Render
org.rapidoid.render.RenderCtx
Expand Down

0 comments on commit 42ccf89

Please sign in to comment.