Retrieving arguments

20 views
Skip to first unread message

wat3r...@gmail.com

unread,
Nov 5, 2015, 11:12:16 AM11/5/15
to rythmengine
Hi All,

Is there any way to retrieve all of the arguments from a template file?

Thanks,
Maria

green

unread,
Nov 5, 2015, 5:31:45 PM11/5/15
to rythm...@googlegroups.com
If you are inside the template, you can find all template argument names by calling @__renderArgTypeMap() method, here is the method signature:
protected Map<String, Class> __renderArgTypeMap()
Once you get the Map, the keySet() is your argument names, and you can use @__get("varName") to retrieve the argument value by name

--
You received this message because you are subscribed to the Google Groups "rythmengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rythmengine...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

wat3r...@gmail.com

unread,
Nov 12, 2015, 12:00:59 PM11/12/15
to rythmengine
Great! Using that method worked! Thanks.

wat3r...@gmail.com

unread,
Dec 2, 2015, 3:17:26 PM12/2/15
to rythmengine
Sorry to open this again.... But, I wasn't trying to get the values of arguments before and didn't test for it. I was able to get the map for arguments and their types. Each argument has a default value. When I try to invoke __get("key"), I always get null. So, I'm doing this all using reflection.

Method getMethod = TemplateBase.class.getDeclaredMethod("__get", String.class);
getMethod.setAccessible(true);
Object o = getMethod.invoke(template, key);

I'm not sure what I'm missing. Any ideas?

Maria

green

unread,
Dec 2, 2015, 3:27:59 PM12/2/15
to rythmengine
You can't get default value using this method. Only passed in argument values can be retrieved. And I don't think it is a good idea to return default value in that __get method because it will slow down the template performance a lot 

wat3r...@gmail.com

unread,
Dec 2, 2015, 3:40:29 PM12/2/15
to rythmengine
Oh ok, what is the best way to get the default value? Or it cannot be retrieved at all?

green

unread,
Dec 2, 2015, 4:06:55 PM12/2/15
to rythmengine
The best way is to reference by their name.  E.g

@args String foo = "bar"
...
@foo @// output bar here

Maria _10

unread,
Dec 2, 2015, 4:58:37 PM12/2/15
to rythm...@googlegroups.com

Is there a way to do that programmatically and not on the template itself?

You received this message because you are subscribed to a topic in the Google Groups "rythmengine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rythmengine/EMK0TDaXb-g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rythmengine...@googlegroups.com.

green

unread,
Dec 2, 2015, 7:54:50 PM12/2/15
to rythm...@googlegroups.com
Not at the moment. If you want please submit a feature request on github.
Reply all
Reply to author
Forward
0 new messages