-
Notifications
You must be signed in to change notification settings - Fork 11
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 {{ gotenberg_font() }}
twig function
#151
base: main
Are you sure you want to change the base?
Add {{ gotenberg_font() }}
twig function
#151
Conversation
bb5fc1c
to
68b1f57
Compare
68b1f57
to
1558cde
Compare
{ | ||
$this->addAsset($path, 'gotenberg_font'); | ||
|
||
$name = htmlspecialchars($name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed ? might be optional and fallback on basename ?
also if htmlspecialchars is needed to be sure it is compatible then I'd check if there are any diff between $name
and htmlspecialchars($name)
to throw error. Because then I assume that this name is referenced by the developper somewhere else right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basename
give us the name with the extension who is not really user friendly I think 🤷♂️
And the value for font-family
can sometimes be an other name.
About htmlspecialchars
, it's more because I put the option is_safe
into the TwigFunction argument, to avoid the default behavior of escaping. https://twig.symfony.com/doc/3.x/advanced.html#automatic-escaping
But I need, I think, to convert special char if the developper pass some wrong values...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe ensure the name is not empty ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Neirda24 You mean empty string? Same for the path argument then?
33b9797
to
985d9a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth creating an issue to allow adding fonts from the configuration itself ?
{ | ||
$this->addAsset($path, 'gotenberg_font'); | ||
|
||
$name = htmlspecialchars($name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe ensure the name is not empty ?
@Neirda24 |
Description
Twig file
The
{{ gotenberg_font() }}
function helps generate an@font-face
declaration with the correct asset path expected by gotenberg.You can provide an absolute path.
Example
Output
And in your controller nothing needs to be changed.
HTML file
If your file is an HTML file (not a Twig template), you can still include fonts manually.
The only requirement is that their paths in the HTML file are on the root level.
All you need to do is to add the path of the asset file to either
assets(...string)
oraddAsset(string)
function.