We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I might be doing something wrong but this doesn't work as I expect:
I have a macro:
{% macro licls(s1, s2 string) %}{% if s1 == s2 %}class="current"{% end %}{% end %}
I use it as:
<li {{licls(s, "home")}}>
The idea was that this renders to either nothing or to class="current".
class="current"
Instead it renders as:
<li class��current�>
It looks like =" and " are garbled
="
"
Here's the repro:
func must(err error) { if err != nil { panic(err) } } func testOne() { navHTML := `{% macro licls(s1, s2 string) %}{% if s1 == s2 %}class='current'{% end %}{% end %} <li {{licls("home", "home")}}> ` fsys := scriggo.Files{ "nav.html": []byte(navHTML), } template, err := scriggo.BuildTemplate(fsys, "nav.html", nil) must(err) err = template.Run(os.Stdout, nil, nil) must(err) }
The text was updated successfully, but these errors were encountered:
This is the expected behavior. Simplifying your example:
{% s := "class='current'" %} <li {{ s }}>
this code is rendered as follows
A string rendered in a tag context can only contain attribute names. It is not safe to allow other characters.
Your example could be rewritten like this
{% licls := func(s1, s2 string) bool { return s1 == s2 } %} <li {% if licls(s, "home") %}class="current"{% end %}>
Sorry, something went wrong.
Close this issue. @kjk feel free to reopen this issue if you have any questions or comments.
No branches or pull requests
I might be doing something wrong but this doesn't work as I expect:
I have a macro:
I use it as:
The idea was that this renders to either nothing or to
class="current"
.Instead it renders as:
It looks like
="
and"
are garbledHere's the repro:
The text was updated successfully, but these errors were encountered: