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

Fix: Convert any value to string when escaping #36

Merged
merged 5 commits into from
Feb 26, 2024

Conversation

wrapperup
Copy link
Contributor

@wrapperup wrapperup commented Feb 25, 2024

Ran into this issue when using autoescape (but this also affects escaping values in general). This ensures any value that is passed into the filter is converted into a string. html.escape expects a string input, it doesn't convert the value automatically for you.

For example, this wouldn't work:

const env = vento({
  autoescape: true
});

const res = env.run("my-template.vto", { number: 10 });
  Error: Error in the template my-template.vto:11:5

  {{ number }}

  > str.replaceAll is not a function

@oscarotero
Copy link
Collaborator

Great.
Can you run deno fmt to fix formatting issues?
Also, it would be nice to add a test for that (in /test/escape.test.ts and /test/unescape.test.ts).
Thanks!

@oscarotero oscarotero merged commit a921536 into ventojs:main Feb 26, 2024
1 check failed
@oscarotero
Copy link
Collaborator

Thank you!

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.

2 participants