Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
theme system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Mar 2013 at 23:31 UTC
Updated:
29 Jul 2014 at 22:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
artofeclipse commentedpatch for core.
Comment #3
artofeclipse commented#1: convert_theme_html_tag_to_twig-1939104-1.patch queued for re-testing.
Comment #5
artofeclipse commentedapply for a new patch
Comment #7
hefox commentededit Issue fixed via #1942490: Make Twig engine available during install
html_tag is used to create a head tag on install (maintenance) page.
Twig is registered via CoreBundle build(), registerTwig(); it is not called during install.php by the time that error is produced.
It works if add
and copy and paste contents of registerTwig() to install.core.inc a bit after line 334
it works.. but that's a lot of copy and pasted code and seems quite unideal.
Saw you posted in #1825788: Symfony fatal when changing maintenance theme about this also, going to link to this comment there.
Comment #8
hefox commentedJust to see that tests will past, adding patch with the copy and pasted items
Comment #10
hefox commentedThat's... odd; just manually went through site install and worked fine.
Comment #11
artofeclipse commented@hefox, thanks for explaining this issue, your patch worked on my local machine, but there was some issues like the css/js not loaded.
Comment #12
hefox commentedLast patch was missing the .html.twig *cross fingers*
Comment #14
hefox commentedThis is failing (at least for first test) because the tests are looking for
<link rel="canonical"but now it looks like<link class="" rel="canonical"From what I recall, Jen etc. want that class=X in there to make it easier for newer people to understand where to add new classes. Personally, I dislike an attribute appearing when empty like that.
So, either class="" needs to not appear or the tests need to be updated/changed or a third+ possibility I haven't thought of.
Comment #15
joelpittetThis passes, locally. Here's hoping. I cheated a bit by letting the {{ attributes }} render the class as we are doing it now so there will be no empty class in the markup. Also, didn't include that registerTwig duplication above.
This whole thing may even just go away due to #1825090: Remove theme_html_tag() from the theme system
Also nice work @hefox and @artofeclipse for getting this started!
Comment #16
joelpittetOh also didn't include an interdiff because the patch in #12 didn't apply, I manually merged.
Comment #18
joelpittethmm, turns out was running tests on wrong site... this should be closer, but still may fail. And the whitespace modifiers were added strategically to pass the tests for ending newline.
Comment #20
joelpittetOh come on, give me a break, one fail "Fatal Error" on HtmlTagUnitTest.php Line 27
The whitespace modifiers I added purposefully leave the ending control's whitespace for a new line. I am going to re-run the tests but if it fails again, maybe someone else can have a look?
Comment #21
joelpittet#18: twig-html-tag-1939104-18.patch queued for re-testing.
Comment #23
star-szrAfter talking to @msonnabaum and @dawehner on IRC about this test fail, @msonnabaum noted that since the unit test is specifically for theme_html_tag(), it should be removed and replaced with a test for template_preprocess_html_tag() to try and test the same logic. We can't test the markup output in this way, but we can still test the logic in template_preprocess_html_tag(), that is used to set up variables for the Twig template.
Also tweaked formatting on a @todo.
Comment #24
star-szrTagging.
Comment #25
star-szrTested manually, no changes in markup and the patch works as expected.
This updates the Twig template to use {% spaceless %} instead of a bucket of whitespace operators and tweaks some documentation.
In my opinion this is ready to go.
Comment #27
star-szrNot quite, maybe the whitespace modifiers need to stay after all.
Comment #28
star-szrGoing to take a look at the tests and see what we should do here.
Comment #29
star-szrI'm going to go with @joelpittet's strategic whitespace modifiers, we are hoping to get rid of this template during consolidation anyway.
Comment #30
star-szrGot rid of a couple of the 'is defined' in the template file and went through a crazy debugging session about why the first one is needed, so I added a comment to the .html.twig file to explain :)
Also tweaked preprocess, don't need to check if #tag is set because #tag is mandatory.
Comment #31
star-szrComment tweak for consistency.
Comment #32
star-szrAssigning to @steveoliver for review.
Comment #32.0
star-szrAdd testing steps
Comment #33
thedavidmeister commentedstealing this for review.
Comment #34
thedavidmeister commentedAt first I couldn't figure out why there were tests for this theme function - I mean, why don't we have tests for the preprocess function of every other theme function? what makes this special?
- // Test auto-closure meta tag generationI think that's the clue.
I believe the point of testThemeHtmlTag() is not to check that the tag coming into the theme function matches the tag coming out but to check that if you provide a "value" you end up with rendered markup that is "regular" HTML tag like
<footag>value</footag>and if you provide no value you end up with a "self closing" HTML tag like<footag attribute="bar" />.The new testPreprocessHtmlTag() intended to replace testThemeHtmlTag() is a much weaker test, it simply checks a few implementation details of the preprocess that have no real bearing on the final rendered HTML tag being closed correctly.
I'm going to say this needs work until the modifications to the tests are "comparing apples to apples".
Comment #35
star-szr#34 - That makes sense, if we want that it can't be a unit test though (as far as I know and based on my work on this issue).
Comment #36
star-szrI can work on a functional test over the next few days.
Comment #37
star-szrOkay, here's an apples to apples test of the theme output :)
Comment #38
thedavidmeister commentedLooks good to me :) Thanks for working on that test, it looks a lot more useful to me now.
Comment #39
tim.plunkettThis looks like another preprocess that could benefit from a switch from 'render element' to 'variables'.
Why the switch? This is :(
Comment #40
star-szr@tim.plunkett - I like the idea of getting rid of another preprocess function but I'm not sure if we can lose the preprocess entirely at this point. For now, I think we'd need something there to get rid of the default theme hook class - see #1938430: Don't add a default theme hook class in template_preprocess(). I'll do some tinkering and see if changing to 'variables' allows us to simplify the preprocess function at all.
As for the unit test to functional test switch: unless I'm mistaken, by definition we cannot unit test the output of a preprocess function + template.
Comment #41
star-szrTo be more specific,
theme_html_tag()is a single function and is unit testable.theme('html_tag', …)ordrupal_render(array('#theme' => 'html_tag', …))invoke hooks and do many other things whether 'html_tag' is implemented as a theme function or as a template.Edited to clarify wording.
Comment #42
star-szrHere's a version using 'variables' instead of 'render element'. If #1938430: Don't add a default theme hook class in template_preprocess() gets in we should be able to drop the preprocess function completely.
Comment #43
star-szrClosing in favour of #1825090: Remove theme_html_tag() from the theme system.
Comment #43.0
star-szrrelated