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

[BUG] Quotes in Tremplate are not rendered correctly ->' is rendered to ' #145

Closed
Raboro opened this issue Mar 8, 2024 · 4 comments

Comments

@Raboro
Copy link

Raboro commented Mar 8, 2024

I have a template for a github action. In this action I trigger a git commit via:

git commit -am "<commit name>"

But if I render no error occur, but it´s not correctly rendered:

git commit -am &amp;#039;<commit name>&amp;#039;

I tried to use ' or \' in my String. But it´s still not generating the ' character arround the commit message.

@Raboro Raboro changed the title [BUG] Quotes in Tremplate are not rendered correctly ->' is rendered to &amp;#039; [BUG] Quotes in Tremplate are not rendered correctly ->' is rendered to &amp;#039; Mar 8, 2024
@PaulDotSH
Copy link
Contributor

I cannot reproduce, both rendering " and ' works perfectly fine for me, can you try to create a minimal reproducible example?

@Raboro
Copy link
Author

Raboro commented Apr 1, 2024

Here is a example:

This is the template: example.stpl:

test: <%= text %>

The template struct:

#[derive(TemplateOnce)]
#[template(path = "example.stpl")]
pub struct Example<'a> {
    pub text: &'a str,
}

and the creation code of the template with print (in prod this would be written to a file):

let example = Example {
    text: "git commit -am 'formatted and clippy'",
};
println!("{}", example.render_once().unwrap());

The console output is:

test: git commit -am &#039;formatted and clippy&#039;

@PaulDotSH
Copy link
Contributor

Here is a example:

This is the template: example.stpl:

test: <%= text %>

The template struct:

#[derive(TemplateOnce)]
#[template(path = "example.stpl")]
pub struct Example<'a> {
    pub text: &'a str,
}

and the creation code of the template with print (in prod this would be written to a file):

let example = Example {
    text: "git commit -am 'formatted and clippy'",
};
println!("{}", example.render_once().unwrap());

The console output is:

test: git commit -am &#039;formatted and clippy&#039;

This is expected behavior as <%= %> sanitizes the input, please try using <%- %> instead. note the - instead of the =

@Raboro
Copy link
Author

Raboro commented Apr 2, 2024

thanks, it´s working now

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

2 participants