Hi I'm new to working with Soy, and also Stash API, i've been trying to figure out how variable data is passed to a soy file. Particularly from java servlet to soy file. I'm looking at examples such as https://developer.atlassian.com/stash/docs/latest/tutorials-and-examples/decorating-the-user-account.html.
In particular the line
<h3>Hello, {$user.displayName}</h3>
I know that displays the user name but where is that User.displayname information coming from. The java file associated makes no reference to user.displayName. Any suggestions will be appreciated.
Thanks
Community moderators have prevented the ability to post new answers.
Hi,
In the example you referred a context is built which is passed to the Soy file:
ImmutableMap.<String, Object>of("user", user)
user
is of type StashUser. Objects that are given to the Soy template in this context are exposed according to the Java Beans standard. You can access a method X#getFoo()
as x.foo
and X#isFoo()
as x.foo
.
You can therefore just use user.displayName
which is using StashUser#getDisplayName() behind the scenes.
Hope this helps.
Cheers,
Michael
Thanks, your explanation makes things alot more clear. So i I wanted to get information not only for just the user, but lets say project information as well, can i pass in a project type, as well as the user type?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure. As far as I know, you can use objects of any class you want as long as you provide the necessary getters to access its properties.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.