What's the right way to create parameters in Soy V2?

1.3k Views Asked by At

Here is my code:

{template .someTemplate}
    {@param? icon : string} /** CSS class that loads and styles the icon */
    {@param? headlineHtml : any} /** Headline text with optional html for styling */
    {@param? textHtml : any} /** Subtext with optional html for styling */
    {@param? buttonText : string} /** The call to action text for the button */
    {@param? rejectButtonText : string} /** The text for choosing to reject the call to action */

....

When I try to compile I get an error saying:

Exception in thread "main" com.google.template.soy.base.SoySyntaxException: In file ./myfile.soy:7, template com.namespace.someTemplate: Not all code is in Soy V2 syntax (found tag {@param? icon : string} not in Soy V2 syntax).`

The only info I've found online seems to suggest this is correct syntax (per Google's site here, per this cheat sheet I found), though, and Googling for "soy v2" has not given me any results that explain what is correct Soy V2 syntax.

What's the correct way to define these parameters?

1

There are 1 best solutions below

0
On

It looks like this is the syntax:

{namespace test}

/**
 * This is a template.
 * @param name The name to say hello to
 */
{template .main}
Hello {$name}
{/template}

I also had trouble finding any documentation. I was getting the same errors saying that the {@param ...} syntax is not valid in V2. Then I found that the examples for soynode (like this one) use the comment syntax. Interestingly, it appears that this new syntax does not include a type definition at all, just a var name.