Hello,
That's me again :) Right now I am just posting bugs/tickets, but one day I'll walk them all will provide patches wherever I can.
This time I have a question about the default template webform-element-base-html.html.twig
.
Right now it reads:
{% if title %}<b>{{ title }}</b><br/>{% endif %}
{{ value }}<br/><br/>
I wonder if those 2 <br/><br/>
at the very end are necessary? I think it's a bit strong assumption to hardcode 2 line breaks at this level of default theme implementation.
Wouldn't it be better to wrap the whole thing into some kind of wrapper and then give it some margin(padding)-bottom. That way other themers can tweak the whole thing the way they need it and nothing is hardcoded.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2842142-better-theming-2.patch | 1.62 KB | bucefal91 |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedwebform-element-base-html.html.twig is used to generate HTML friendly emails. Using <br/> tags for spacing is the simplest and most reliable way to add spacing in an HTML email.
Themers looking to send more complex HTML emails can override this template and add inline styles.
Comment #3
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedMaybe something like this? I know my patch is still long way from the ideal solution, but I hope you can see my point - introducing attributes with the idea that these attributes can then be manipulated through other (pre)-process functions (presumably in custom themes) and your base
webform-element-base-html.html.twig
becomes much more flexible. There's no need to override the template since this way the majority of tasks can be applied via manipulating the attributes and then doing necessary CSS in the custom theme.And you also will have probably better time defining standard CSS classes in
template_preprocess_webform_element_base_html()
, just like Field API or Views does it.You see my logic here?
Comment #4
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedCrap, the patch somehow got forgotten. I attach it now.
Comment #5
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedahhh, and it needs "needs review" status.
Comment #7
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedI've just looked through the test failures. They all fail because the HTML output of
webform-element-base-html.html.twig
has changed.If you like my suggestion I can adapt the tests so they start passing with the new approach.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer commented@bucefal91 Check out the below article which helps explains why we should avoid using classes (and a lot of other features) in any HTML email related markup.
https://css-tricks.com/using-css-in-html-emails-the-real-story/
Personally, I want the Webform's templates to be as simple as possible, while making it possible for all templates to overridden. Maybe someone can write a blog post about building custom and most advanced HTML email template overrides for the Webform module.
Comment #9
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedHello!
Yes, I understand your position. Then I'll do what I need in a custom theme.
Comment #10
krishanchandra CreditAttribution: krishanchandra at Publicis Sapient commentedWe can theme our webform through custom twig.
We need to set this in
<theme_name >.theme
fileAfter this code we can use
example-webform_template-name.html.twig
for our webform theming.