It's not necessary anymore to apply the 'safe' filter on the 'truncatesentences_html'-filter.

This commit is contained in:
Florian Schlachter 2014-10-01 22:18:12 +02:00
parent 4a22cf2ef9
commit 640ef3ff28
2 changed files with 3 additions and 3 deletions

View File

@ -215,7 +215,7 @@ func filterTruncatesentencesHtml(in *pongo2.Value, param *pongo2.Value) (*pongo2
return idx return idx
}, func() {}) }, func() {})
return pongo2.AsValue(new_output.String()), nil return pongo2.AsSafeValue(new_output.String()), nil
} }
func filterTimeuntilTimesince(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, error) { func filterTimeuntilTimesince(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, error) {

View File

@ -77,10 +77,10 @@ func (s *TestSuite1) TestFilters(c *C) {
Equals, "This is a first sentence with a 4.50 number. The second one is even more fun! Isn't it?") Equals, "This is a first sentence with a 4.50 number. The second one is even more fun! Isn't it?")
// Truncatesentences_html // Truncatesentences_html
c.Assert(pongo2.RenderTemplateString("{{ text|truncatesentences_html:2|safe }}", pongo2.Context{ c.Assert(pongo2.RenderTemplateString("{{ text|truncatesentences_html:2 }}", pongo2.Context{
"text": `<div class="test"><ul><li>This is a first sentence with a 4.50 number.</li><li>The second one is even more fun! Isn't it?</li><li>Last sentence, okay.</li></ul></div>`}), "text": `<div class="test"><ul><li>This is a first sentence with a 4.50 number.</li><li>The second one is even more fun! Isn't it?</li><li>Last sentence, okay.</li></ul></div>`}),
Equals, `<div class="test"><ul><li>This is a first sentence with a 4.50 number.</li><li>The second one is even more fun!</li></ul></div>`) Equals, `<div class="test"><ul><li>This is a first sentence with a 4.50 number.</li><li>The second one is even more fun!</li></ul></div>`)
c.Assert(pongo2.RenderTemplateString("{{ text|truncatesentences_html:3|safe }}", pongo2.Context{ c.Assert(pongo2.RenderTemplateString("{{ text|truncatesentences_html:3 }}", pongo2.Context{
"text": `<div class="test"><ul><li>This is a first sentence with a 4.50 number.</li><li>The second one is even more fun! Isn't it?</li><li>Last sentence, okay.</li></ul></div>`}), "text": `<div class="test"><ul><li>This is a first sentence with a 4.50 number.</li><li>The second one is even more fun! Isn't it?</li><li>Last sentence, okay.</li></ul></div>`}),
Equals, `<div class="test"><ul><li>This is a first sentence with a 4.50 number.</li><li>The second one is even more fun! Isn't it?</li></ul></div>`) Equals, `<div class="test"><ul><li>This is a first sentence with a 4.50 number.</li><li>The second one is even more fun! Isn't it?</li></ul></div>`)
} }