-
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
Make Twig dependency optional #12
Conversation
I think you can work with @StevenRenaux to make a unique PR. See #11. |
src/Builder/TwigTrait.php
Outdated
* | ||
* @throws PdfPartRenderingException if the template could not be rendered | ||
*/ | ||
public function renderPart(PdfPart $pdfPart, string $template, array $context = []): self |
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 we can find a better name, WDYT ? HTML has htmlContent
, what about twigContent
, twigHeader
and twigFooter
? They can use a protected renderPart
method.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
the twig*
prefix will be needed since this trait is used in the HtmlPdfBuilder
class which has already a htmlContent
method (or just content
).
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.
Why does HtmlBuilder need Twig ? The whole point of this PR was to not have this depdency. Or am I missing something ?
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.
It doesn't "need" Twig, the dependency is optional and the method checks if Twig is available.
Are you suggesting to keep the TwigBuilder? As we've discussed it, it wouldn't make sense IMHO since every chromium route could be called with rendered templates.
src/Builder/HtmlPdfBuilder.php
Outdated
/** | ||
* The HTML file to convert into PDF. | ||
*/ | ||
public function htmlContent(string $filePath): self |
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.
why the prefix html ? We are in a HtmlBuilder
context. content
should suffice IMO. Same goes for header / footer
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.
I renamed the twig method to content
and the HTML file method to contentFile
src/Builder/TwigTrait.php
Outdated
* | ||
* @throws PdfPartRenderingException if the template could not be rendered | ||
*/ | ||
public function renderPart(PdfPart $pdfPart, string $template, array $context = []): self |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/Pdf/Gotenberg.php
Outdated
$builder->setConfigurations($this->userConfigurations); | ||
|
||
if (null !== $htmlTemplate) { | ||
$builder->htmlTemplate($htmlTemplate); |
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.
what is htmlTemplate in context of markdown ?
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.
It's the HTML file that wraps the markdown content (https://gotenberg.dev/docs/routes#markdown-files-into-pdf-route). I renamed it to htmlWrapper
for rendering with Twig and htmlWrapperFile
for HTML files, WDYT?
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.
Some little comments before approving 🙂
Fixes #1 - Make TwigBundle dependency optional + some refactoring
Allow passing required options to the builder from GotenbergInterface