Meta issue: #1843738: [meta] Convert views module to Twig
#1987510: [meta] Convert all core *.tpl.php templates to Twig as singular patch

Profiling results

=== views-view-rss-8.x..views-view-rss-8.x compared (519aa9d3a1b8c..519aaa3d27345):

ct  : 41,342|41,342|0|0.0%
wt  : 267,443|267,501|58|0.0%
cpu : 251,455|250,983|-472|-0.2%
mu  : 18,107,976|18,107,976|0|0.0%
pmu : 18,186,400|18,186,400|0|0.0%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=519aa9d3a1b8c&...

=== views-view-rss-8.x..views-view-rss-1843760-32 compared (519aa9d3a1b8c..519aaa62743ee):

ct  : 41,342|41,424|82|0.2%
wt  : 267,443|267,876|433|0.2%
cpu : 251,455|251,969|514|0.2%
mu  : 18,107,976|18,140,752|32,776|0.2%
pmu : 18,186,400|18,212,776|26,376|0.1%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=519aa9d3a1b8c&...

Comments

joelpittet’s picture

Status: Active » Needs review
StatusFileSize
new912 bytes
mbrett5062’s picture

Issue tags: +VDC

Tagging.

jpamental’s picture

StatusFileSize
new1.86 KB

Converted to core patch. Removes views-view-rss.tpl.php, adds views-view-rss.html.twig

jpamental’s picture

Project: » Drupal core
Version: » 8.x-dev
Component: Twig templates conversion (front-end branch) » views.module

Reassigning to Drupal core.

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, drupal-twig-views-view-rss-1843760.patch, failed testing.

idflood’s picture

Status: Needs work » Needs review
Issue tags: +VDC
dawehner’s picture

+++ /dev/nullundefined
@@ -1,20 +0,0 @@
-<?php print "<?xml"; ?> version="1.0" encoding="utf-8" <?php print "?>"; ?>

+++ b/core/modules/views/templates/views-view-rss.html.twigundefined
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8" ?>

Just this line shows how much better twig is :)

+++ b/core/modules/views/templates/views-view-rss.html.twigundefined
@@ -0,0 +1,28 @@
+ * - link: link to the feed (the view path)
+ * - namespaces: XML namespaces (added automatically)
+ * - title: title (as set in the view)
+ * - description: feed description (from feed settings)
+ * - langcode: language encoding
+ * - channel_elements: the formatted channel elements

I'm wondering whether you know what the codestyle tells us about these descriptive lines. Should they be full sentences?

This looks really great in general.

jpamental’s picture

@dawehner I confess I don't really know. There were no comments in the original patch or file, so I write these in as best I could. I don't know if there is a format I was supposed to follow, though if there is point me in the right direction and I'll reroll it!

star-szr’s picture

The general guidelines are that all documentation should form complete sentences (http://drupal.org/node/1354#drupal) and the template documentation standards show this in action (http://drupal.org/node/1354#templates). There's also the Twig-specific standards, I think for example the @ingroup views_templates needs to be @ingroup themeable.

dawehner’s picture

Status: Needs review » Needs work

So needs work, sorry.

joelpittet’s picture

Issue tags: +Twig

Adding twig tag

webthingee’s picture

Assigned: Unassigned » webthingee

grabbing

joelpittet’s picture

Title: Convert views/theme/views-view-rss.tpl.php to twig » Convert views/templates/views-view-rss.tpl.php to twig
webthingee’s picture

Status: Needs work » Needs review
StatusFileSize
new370.89 KB
new1.08 KB

updating documentation.
used views-exposed-form.html.twig as a guide/sample and used both @ingroup statements.

webthingee’s picture

Status: Needs review » Needs work
webthingee’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB
new9.88 KB
webthingee’s picture

Status: Needs review » Needs work
webthingee’s picture

Status: Needs work » Needs review
StatusFileSize
new1.89 KB
new1.08 KB

This time I GOT IT.

joelpittet’s picture

Nice work, if you want you can uppercase the first letter on those sentences as well.

Also we can clean up the docs and variables on the preprocess function

/**
 * Preprocess an RSS feed
 */
function template_preprocess_views_view_rss(&$vars) {

replacing $vars with $variables

  $view     = &$vars['view'];
  $options  = &$vars['options'];
  $items    = &$vars['rows'];

  $style    = &$view->style_plugin

And removing the spaces infront of these variables.

star-szr’s picture

Issue tags: +Needs manual testing

Tagging.

thedavidmeister’s picture

Status: Needs review » Needs work

#19 - We don't have to convert the $vars to $variables just yet, that's a task for another day #1963942: Change all instances of $vars to $variables.

This is a very minor point but could we add @see template_preprocess() to the template comments?

Other than that though I think the code style in this patch is good. Essentially, once the documentation is updated it's ready for manual testing and for manual testing steps to be written :)

star-szr’s picture

Tagging as novice to add @see template_preprocess() to the .html.twig between the variables and the @ingroup, see Twig coding standards for an example.

+++ b/core/modules/views/templates/views-view-rss.html.twigundefined
@@ -0,0 +1,29 @@
+ * - link: link to the feed (the view path).
+ * - namespaces: XML namespaces (added automatically).
+ * - title: title (as set in the view).
+ * - description: feed description (from feed settings).
+ * - langcode: language encoding.
+ * - channel_elements: the formatted channel elements.
+ * - items: the feed items themselves.

Also, these descriptions should be complete sentences (starting in a capital letter) per http://drupal.org/node/1354#drupal.

star-szr’s picture

Issue tags: +Novice

Oops, tag.

If you'd like to work on this, please assign the issue to yourself. If you get stuck, drop by #drupal-twig on IRC or post your questions here. Thanks!

star-szr’s picture

I didn't notice this was already assigned.

@webthingee - same as #1843740: Convert views/templates/views-exposed-form.tpl.php to twig, you're more than welcome to see this through but if you can't for whatever reason please unassign.

webthingee’s picture

StatusFileSize
new1.96 KB

#21 held off on any variables.
#22 added @see template_preprocess()
#22 updated docs to complete sentences.

Ended up with a fresh patch after updating latest 8.x repo.

webthingee’s picture

Status: Needs work » Needs review

setting this patch to needs review.

webthingee’s picture

StatusFileSize
new1.96 KB

looking at code standards again, seeing I need an extra space.
re-rolled....

jenlampton’s picture

Assigned: webthingee » Unassigned
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs manual testing

Okay, testing manually. Markup looks good! Doc block looks great. :)

before:

<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="http://d8core.dev/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  <channel>
    <title>Drupal 8</title>
    <link>http://d8core.dev/</link>
    <description></description>
    <language>en</language>
    ...
  </channel>
</rss>

after:

  <?xml version="1.0" encoding="utf-8" ?>
  <rss version="2.0" xml:base="http://d8core.dev/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
    <channel>
      <title>Drupal 8</title>
      <link>http://d8core.dev/</link>
      <description></description>
      <language>en</language>
      ...
    </channel>
  </rss>

Since #25 passed tests and #27 just adds another space, I'm confident marking this RTBC :)

dawehner’s picture

This looks perfect!

thedavidmeister’s picture

Issue tags: -Novice
star-szr’s picture

Issue tags: +needs profiling

Tagging for profiling.

joelpittet’s picture

StatusFileSize
new3.85 KB
new2.52 KB

Doc updates, missing preprocess docs. Removed $options because they weren't being used and =& references.

star-szr’s picture

Assigned: Unassigned » star-szr

I'll profile this one.

star-szr’s picture

Assigned: star-szr » Unassigned
Issue tags: -needs profiling

Profiling results:

Added this code to template_preprocess_views_view_rss() to isolate the profiling to only this template conversion (not comparing loading Twig itself):

  $node = node_load(101);
  $vars['description'] .= theme('node', node_view($node));
=== views-view-rss-8.x..views-view-rss-8.x compared (519aa9d3a1b8c..519aaa3d27345):

ct  : 41,342|41,342|0|0.0%
wt  : 267,443|267,501|58|0.0%
cpu : 251,455|250,983|-472|-0.2%
mu  : 18,107,976|18,107,976|0|0.0%
pmu : 18,186,400|18,186,400|0|0.0%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=519aa9d3a1b8c&...

=== views-view-rss-8.x..views-view-rss-1843760-32 compared (519aa9d3a1b8c..519aaa62743ee):

ct  : 41,342|41,424|82|0.2%
wt  : 267,443|267,876|433|0.2%
cpu : 251,455|251,969|514|0.2%
mu  : 18,107,976|18,140,752|32,776|0.2%
pmu : 18,186,400|18,212,776|26,376|0.1%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=519aa9d3a1b8c&...

star-szr’s picture

Issue summary: View changes

Updated issue summary.

alexpott’s picture

Title: Convert views/templates/views-view-rss.tpl.php to twig » [READY] Convert views/templates/views-view-rss.tpl.php to twig
Status: Reviewed & tested by the community » Closed (duplicate)

+1. Ready for #1987510: [meta] Convert all core *.tpl.php templates to Twig as singular patch

+++ b/core/modules/views/templates/views-view-rss.html.twigundefined
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8" ?>

+++ /dev/nullundefined
@@ -1,20 +0,0 @@
-<?php print "<?xml"; ?> version="1.0" encoding="utf-8" <?php print "?>"; ?>

Yay!

alexpott’s picture

Title: [READY] Convert views/templates/views-view-rss.tpl.php to twig » Convert views/templates/views-view-rss.tpl.php to twig
Status: Closed (duplicate) » Fixed

Committed a312df8 and pushed to 8.x. Thanks!

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

Anonymous’s picture

Issue summary: View changes

Add profiling results