Fixed dead link on Tera reference#33
Closed
Arteneko wants to merge 3 commits intoKeats:masterfrom
Arteneko:master
Closed
Fixed dead link on Tera reference#33Arteneko wants to merge 3 commits intoKeats:masterfrom Arteneko:master
Arteneko wants to merge 3 commits intoKeats:masterfrom
Arteneko:master
Conversation
Keats
reviewed
Jan 28, 2020
| .filter_map(|e| e.ok()); | ||
|
|
||
| // Register the `slug` filter | ||
| Tera::default().register_filter("slugify", |value, _| slugify(value)); |
Owner
There was a problem hiding this comment.
That's not how you register it, this is dropping the Tera instance right away. Since the code uses Tera::one_off a few times, it's probably better to have a function to render a template that looks like
fn render_template(content, context) -> Result<String> {
let mut tera = Tera::default();
tera.register_filter("slugify", |value, _| slugify(value));
tera.add_raw_template("one_off", content)?;
let res = tera.render("one_off", &context).map_err(|err| new_error(ErrorKind::Tera { err, path: None }))?;
Ok(res)
}or something similar
Contributor
Author
There was a problem hiding this comment.
Thanks for the insight.
I thought for a second that Tera::default() was referring to a static instance.
Contributor
Author
|
I fucked up the PR, I aimed to only fix the README. I'll create a new PR with only the README's changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.