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

Add new "partials" syntax for pegasus templates #28118

Merged
merged 10 commits into from Jun 13, 2019

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented Apr 19, 2019

Specifically, pegasus templates that use a rendering engine that does not have native support for partials (particularly markdown).

The implementation simply requires you to add the new extension partial to the file, then you can include any partial within the views directory with the syntax {{ * }}, where * can be the (extensionless) name of any existing partial. The contents of the partial will be included in the template file upon render.

For example, renaming hints.md to hints.md.partial and adding {{ testimonials }} to hints.md results in:

image

Also add protection against directory transversal in our template rendering in general; we already sort of protect against this by escaping periods in URIs, but we don't currently protect against this in the existing view tags.

@Hamms
Copy link
Contributor Author

Hamms commented Apr 19, 2019

also see #28120 for an example of the kind of conversion we'd want to apply to all our markdown templates under such a scheme

@Hamms Hamms changed the title Proof-of-concept for markdown with partials in pegasus Add new "partials" syntax for pegasus templates Jun 11, 2019
@Hamms Hamms marked this pull request as ready for review June 11, 2019 18:51
#
# Because such content can be translated, we want to make sure that if a
# translator accidentally translates the path to the template, we simply
# render nothing rather than throwing an error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth tracking these errors somewhere (not sure how)? We could occasionally go through all of the invalid template paths and fix any caused by translations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I like that! We could probably register a honeybadger error here but still show the page. I'll add a Jira item for this.

@Hamms Hamms merged commit fb0e17c into staging Jun 13, 2019
@Hamms Hamms deleted the markdown-partials-in-pegasus branch July 2, 2019 21:44
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.

None yet

3 participants