Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support @param syntax in templates #70

Open
rehmsen opened this issue Mar 14, 2019 · 4 comments
Open

Support @param syntax in templates #70

rehmsen opened this issue Mar 14, 2019 · 4 comments

Comments

@rehmsen
Copy link

rehmsen commented Mar 14, 2019

The documentation for Closure Templates has examples of the param syntax:

{template .helloName}
  {@param name: string}
  Hello {$name}!
{/template}

This parser does not seem to support that though - I get:

lexical error: unrecognized character in action: U+0040 '@'

I think an older syntax for the same was to use comments:

/** 
 * @param name
 */

But that is no longer supported by some other parsers we use, and this one which does not support the new one. I think I would be great to add support for this.

I might be able to contribute something - is somebody already aware of this issue or has tried to fix it? Any pointers?

@robfig
Copy link
Owner

robfig commented Mar 26, 2019

When I initially wrote this project, I thought Soy was in stable maintenance mode, but it turned out that the team has continued to add features / change existing ones, and I haven't even tried to keep pace.

I'd certainly be happy to work with you on pull requests adding parity features if you're interested to work on it. In full disclosure, I also wanted to point out that there's an alternative which uses the official JS implementation on otto (a js interpreter in Go): https://code.taxi/socialworkout/soyotto. That repo also has a reference to Google's internal Go soy renderer. It looks like he's opted out of Github, but maybe @hochhaus could weigh in on if there's any interest on Google's part in open source it.

@hochhaus
Copy link

hochhaus commented Mar 26, 2019

Hi @rehmsen and @robfig. Glad to see interest in go closure templates. I left Google in 2008 so I can't comment on their interest level in open sourcing pure go closure templates code. If I had to guess, chances are low since we have not seen any code thus far. Unfortunately, I also can't recommend using soyotto as I am no longer maintaining it and it is not in active use for any projects (as far as I am aware).

@rehmsen
Copy link
Author

rehmsen commented Mar 26, 2019

Thanks for the response, @robfig and @hochhaus. We have in the meanwhile found another work around. We are only using this library for a small development server and it was not worth it on our end to update the lexer/parser to work with the new feature. So feel free to keep this open or close it, as you see fit.

@q3k
Copy link

q3k commented Nov 11, 2019

For what it's worth, I've quickly hacked together non-soydoc (gonna call it 'native' from now on) parameter syntax in templates over at https://github.com/q3k/soy/tree/q3k/non-soydoc-params .

If there's interest, I can spend a bit more time to support default parameters and generally clean this up, and send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants