We have a template file named datetime.html.twig in the system module, but it outputs a HTML5 <time> tag, it should be renamed time.html.twig.

This change also helps avoid confusion with '#type' => 'datetime' which outputs a datetime form element.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nod_’s picture

Title: wrong name for datetime.html.twig » Wrong name for datetime.html.twig should be time.html.twig
Issue tags: +markup

tag

naveenvalecha’s picture

Taking this one.

naveenvalecha’s picture

Status: Active » Needs review
FileSize
247 bytes

Attached patch for this small change.

naveenvalecha’s picture

Please someone reroll the patch to update the documentation in the twig file.

Status: Needs review » Needs work

The last submitted patch, datetime.html_.twig-to-time.html_.twig-2088365-3.patch, failed testing.

undertext’s picture

Assigned: Unassigned » undertext
undertext’s picture

Does this means that form element must be renamed to 'time' e.g

  $form['some'] = array(
    '#type' => 'datetime',
  );

must be

  $form['some'] = array(
    '#type' => 'time',
  );
nod_’s picture

The form element is a different matter, time tag is not a form element at all. It's just for display.

For form types, see #2088383: Datetime FAPI DX.

star-szr’s picture

To make this change you will need to update drupal_common_theme() as well:

https://api.drupal.org/api/drupal/core%21includes%21theme.inc/function/d...

Usually the template name matches up with the theme hook name - so I would suggest updating the theme hook to 'time', so that it is rendered via '#theme' => 'time' rather than '#theme' => 'datetime'.

undertext’s picture

undertext’s picture

Status: Needs work » Needs review
star-szr’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

That's great, thanks @undertext! Looks like this needs a reroll now.

We'll also need to update template_preprocess_datetime() to template_preprocess_time() - this is referenced in a @see in the Twig template.

The ideal result here will be a rerolled patch, an interdiff, and then a revised patch. The interdiff will show the differences between the rerolled patch and the revised patch (that updates the preprocess function).

grisendo’s picture

grisendo’s picture

And now the template_preprocess_time change and interdiff

grisendo’s picture

Assigned: undertext » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll

Status: Needs review » Needs work
herom’s picture

Status: Needs work » Needs review

the patch is green, so... needs review.

grisendo’s picture

Sorry, I forgot to set interdiff extension to .txt to avoid testing it :(

LinL’s picture

sriharsha.uppuluri’s picture

Assigned: Unassigned » sriharsha.uppuluri
Status: Needs work » Needs review
FileSize
3.23 KB
5.38 KB

Uploading the rerolled patch.

saltednut’s picture

star-szr’s picture

Status: Needs review » Needs work
Issue tags: +Twig

Thanks @sriharsha.uppuluri!

We need to rename template_preprocess_datetime() like in #14.

sriharsha.uppuluri’s picture

Status: Needs work » Needs review
FileSize
4.08 KB
2.89 KB

Thanks @Cottser

Renamed template_preprocess_datetime() like in #14.

Status: Needs review » Needs work

The last submitted patch, 23: datetime.html_.twig-to-time.html_.twig-2088365-23.patch, failed testing.

visabhishek’s picture

Status: Needs work » Needs review
FileSize
723 bytes
6.04 KB

i am updating patch #20 based on #22 comments.

sriharsha.uppuluri’s picture

Assigned: sriharsha.uppuluri » Unassigned
star-szr’s picture

Status: Needs review » Needs work

Looking good, one minor tweak needed then this should be ready to go:

+++ b/core/includes/theme.inc
@@ -997,7 +997,7 @@ function theme_disable($theme_list) {
- * Preprocess variables for theme_datetime().
+ * Preprocess variables for theme_time().

While we're updating this it should follow our newer documentation standards for preprocess functions:

Preprocess function documentation standards

…and in particular it shouldn't refer to theme_time() because that doesn't exist :)

cs_shadow’s picture

Status: Needs work » Needs review
FileSize
4.36 KB

Changed the patch in #25 to incorporate changes suggested in #27.

The doc block now looks like:

/**
 * Preprocess variables for time templates.
 *
 * Default template: time.html.twig.
 *
 * @param array $variables
star-szr’s picture

Thanks @cs_shadow!

Interdiff next time, please! And "Preprocess" should be "Prepares" according to the documentation standards.

cs_shadow’s picture

Changed the patch as suggested in #29. Attaching interdiff.

The last submitted patch, 28: drupal-wrong_name_for_datetime.html_.twig-2088365-28.patch, failed testing.

cs_shadow’s picture

Trying to fix the errors in #28.

The last submitted patch, 30: drupal-wrong_name_for_datetime.html_.twig-2088365-30.patch, failed testing.

matthewmessmer’s picture

Assigned: Unassigned » matthewmessmer

I'm at the Austin core mentoring spring and I am going to reroll the latest patch.

matthewmessmer’s picture

Patch #32 failed to apply due to renaming of core/modules/datetime/lib directory to core/modules/datetime/src.

Tried to create interdiff but could not reroll patch due to corrupt patch error when applying.

Recreated patch to match latest core version.

selfuntitled’s picture

Status: Needs review » Reviewed & tested by the community

At Drupalcon Austin - just tested patch in #35. Applies cleanly, looks to remove all references to datetime.html.twig updated to reviewed and tested.

catch’s picture

Status: Reviewed & tested by the community » Needs review

Not sure about this, while the HTML5 element is called 'time', the thing being formatted is a datetime (and the HTML5 spec allows a datetime attribute for that element). The whole point of the template is to allow for changing the markup, which could include using a different element.

nod_’s picture

We do have select.html.twig, table.html.twig, textarea.html.twig, form.html.twig,fieldset.html.twig, details.html.twig, html.html.twig and also image.html.twig.

( edit ) since template deal with HTML, it should be pretty clear to everyone it's the HTML meaning of time that is used.

joelpittet’s picture

Issue tags: +Needs change record

@catch, I was thinking along the same lines as you, it's such a blurry line here. Also very minor, I'd recommend making this change.

@_nod, I so wish we weren't so granular in the templates and let the templates live at a more component level or view mode level. That, or we may as well create a template for the whole html spec of tags. And the more granular the slower on the io and rendering... sorry I had to rant because I see these single tag templates with very little context and wonder how anybody builds a site in a reasonable amount of time with that level of templates. Like trying to build a fence and all you have is toothpicks. Oh and sorry because you may not be the right person to rant in the direction...
but seeing them listed out just made me go "argh".

This may need a small change record though?

bradklaver’s picture

Assigned: matthewmessmer » Unassigned
FileSize
6.05 KB

Re-rollling machostache 's patch in comment #35.

star-szr’s picture

Status: Needs review » Needs work

Thanks @bradklaver!

This wasn't introduced by the reroll, but there's something broken. This also means we have little to no test coverage for the aggregator_summary_item theme hook (I hacked core to even get it to be used). The tests can probably be added in another issue, no need to hold this one up.

+++ b/core/modules/aggregator/aggregator.theme.inc
@@ -118,7 +118,7 @@ function template_preprocess_aggregator_summary_item(&$variables) {
   $variables['age'] = array(
     '#theme' => 'datetime',
     '#attributes' => array(
-      'datetime' => format_date($item->getPostedTime(), 'html_datetime', '', 'UTC'),
+      'time' => format_date($item->getPostedTime(), 'html_datetime', '', 'UTC'),
       'class' => array('feed-item-age',),
     ),
     '#text' => t('%age old', array('%age' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $item->getPostedTime()))),

'#theme' should be changed to 'time' here and the attribute should remain as 'datetime'. See http://www.brucelawson.co.uk/2012/best-of-time/.

CharuAg’s picture

Status: Needs work » Needs review
FileSize
5.88 KB
801 bytes

Addressed comment 41.

star-szr’s picture

Issue to add tests created: #2325501: Add test coverage for output of aggregator_summary_item theme hook

This needs a small change record then it can be RTBC.

star-szr’s picture

Assigned: Unassigned » star-szr

Working on the change record.

star-szr’s picture

Assigned: star-szr » Unassigned
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice, -Needs change record +Quick fix
FileSize
2.93 KB
740 bytes
  • Change record draft is up: https://www.drupal.org/node/2326617
  • Added a note about '#type' => 'datetime' to the issue summary.
  • Making a minor documentation tweak to the patch.

RTBC!

Patch is smaller because I have this in my .gitconfig:

[diff]
	renames = copies
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Good catch.

Committed and pushed to 8.x. Thanks!

  • webchick committed 1b25220 on 8.0.x
    Issue #2088365 by Cottser, CharuAg, bradklaver, machostache, cs_shadow,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.