Skip to content

Add WithNoEscape(bool) function to disable HTML escaping globally#4

Open
lambdalisue wants to merge 2 commits intoflowchartsman:mainfrom
lambdalisue:main
Open

Add WithNoEscape(bool) function to disable HTML escaping globally#4
lambdalisue wants to merge 2 commits intoflowchartsman:mainfrom
lambdalisue:main

Conversation

@lambdalisue
Copy link

Handlebars support noEscape option and this PR add such feature with functional options pattern.

Now users can use WithNoEscape() like

source := `<div class="entry">
  <h1>{{title}}</h1>
  <div class="body">
    {{body}}
  </div>
</div>
`

ctx := map[string]string{
    "title": "All about <p> Tags",
    "body":  "<p>This is a post about &lt;p&gt; tags</p>",
}

tpl := handlebars.MustParse(source, handlebars.WithNoEscape(true))
result := tpl.MustExec(ctx)

fmt.Print(result)

I'm not sure if my changes are enough for noEscape option so let me know additional changes are required

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

Successfully merging this pull request may close these issues.

1 participant