Hey there, guys. Which ducks do I need to get in a row to make a Soy function work in a Stash plugin? Here's what I have so far:
I can see that the Soy function's constructor is called during plugin start-up, but none of the other methods. The atlassian-stash.log shows this when I refresh the page containing the function call:
com.google.template.soy.base.SoySyntaxException: In file file:/blahblah/mytemplate.soy:25: Unrecognized function 'nav_test' (function call "nav_test()").
It seems that the function isn't getting registered properly. What have I missed?
Community moderators have prevented the ability to post new answers.
Hey Dave - sorry for the late reply.
You should have it bang on. Here is what you will need to export a soy function in a plugin. Let me know if you are still having trouble
1. pom.xml depends on stash-template-renderer-api
<dependency> <groupId>com.atlassian.soy</groupId> <artifactId>soy-template-renderer-api</artifactId> <version>1.1.7</version> </dependency>
2. Define your function in your atlassian-plugin.xml
<soy-function key="name-of-soy-function" class="com.my.plugin.MyNavFunction"/>
3. Implement com.my.plugin.MyNavFunction extends SoyServerFunction<String>
4. Reference your function as you defined getName() in your implementation.
From what I can tell, you haven't actually missed anything. Are you calling it from a web panel served from your plugin, or are you rendering a servlet which is decorated by Stash?
Thanks Seb. I understand that you might be busy at the moment.
I'm calling the function from a template that is being rendered directly from a servlet. I've got around the problem by simply injecting the URL (which I had wanted the function to return) into the template as model data. Just wondered why it didn't seem to work for me. Not to worry; my work-around is adequate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
David, feel free to get in touch directly if you need anything from me or if you have any questions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.