convert core/modules/field/field.module theme_field() to twig

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

shlapa’s picture

Status: Needs work » Needs review
FileSize
1.7 KB
podarok’s picture

Status: Needs review » Needs work

wrong diff

shlapa’s picture

Status: Needs work » Needs review
FileSize
1.7 KB

corrected patch

podarok’s picture

Status: Needs review » Needs work
+++ b/core/themes/stark/templates/field/field.twig
@@ -0,0 +1,30 @@
+      <div class="field-item {{ cycle(["even", "odd"], delta) }}"
+	  {{ item_attributes[delta]}}>{{ render(item) }}</div>
+    {% endfor %}

no tabs - use whitespaces

+++ b/core/themes/stark/templates/field/field.twig
@@ -0,0 +1,30 @@
+</div>
\ No newline at end of file

No newline at end of file

shlapa’s picture

Status: Needs work » Needs review
FileSize
3.01 KB

fixes after code review

shlapa’s picture

Status: Needs review » Needs work
podarok’s picture

Status: Needs work » Needs review
+++ b/core/modules/field/field.module
@@ -1113,9 +1114,9 @@ function template_process_field(&$variables, $hook) {
-  $variables['attributes'] = isset($variables['attributes']) ? drupal_attributes($variables['attributes']) : clone $default_attributes;
-  $variables['title_attributes'] = isset($variables['title_attributes']) ? drupal_attributes($variables['title_attributes']) : clone($default_attributes);
-  $variables['content_attributes'] = isset($variables['content_attributes']) ? drupal_attributes($variables['content_attributes']) : clone($default_attributes);
+  $variables['attributes'] = isset($variables['attributes']->storage) ? drupal_attributes($variables['attributes']->storage) : clone($default_attributes);
+  $variables['title_attributes'] = isset($variables['title_attributes']->storage) ? drupal_attributes($variables['title_attributes']->storage) : clone($default_attributes);
+  $variables['content_attributes'] = isset($variables['content_attributes']->storage) ? drupal_attributes($variables['content_attributes']->storage) : clone($default_attributes);

better not use restyling in patches
but I think we can RTBC here

all other code looks good

andypost’s picture

Suppose attributes are unified in http://drupal.org/node/1727592 and probably this branch a bit outdated
Also related #1623574: Remove trailing space from form element labels and field labels (HTML nbsp)

podarok’s picture

Status: Needs review » Postponed
shlapa’s picture

Status: Postponed » Needs review
FileSize
3.1 KB

final version for now...
most of variables are already Attributes objects, except mentioned as FIXME in patch.
trailing space removed

podarok’s picture

podarok’s picture

Status: Needs review » Needs work

due to #1779136: Weekly - Merge Twig sandbox with latest HEAD

git apply --check 1779034-field10.patch
error: patch failed: core/modules/field/field.module:1113
error: core/modules/field/field.module: patch does not apply

need reroll

podarok’s picture

Component: Code » Twig templates

commited #10 to 8.x branch

podarok’s picture

Status: Needs work » Fixed

status

Status: Fixed » Closed (fixed)

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

Fabianx’s picture

Status: Closed (fixed) » Needs work

Reopened due to not having been merged correctly to front-end branch.

Needs re-roll.

oseldman’s picture

Status: Needs work » Closed (fixed)

Patch from #10 applied cleanly, but field.html.twig had already been placed properly in the directory. I committed the changes to field.module.