I was doing some exploration of the core theme functions and found it odd that the theming example module recommends a template file with underscores in the filename, whereas all of core uses dashes.

Proposed change would be twofold:

1) rename the theming_example_text_form.tpl.php file to theming-example-text-form.tpl.php, changing its reference in the hook_theme() implementation of the module.
2) Add verbiage to the hook_theme "template" variable code comment, to explicitly recommend the best practice of using dashes in template files.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jwilson3’s picture

Issue tags: +Novice

Tagging.

webchick’s picture

Project: Drupal core » Examples for Developers
Version: 8.x-dev » 8.x-1.x-dev
Component: theme system » Theming Example

Theme example module? I'm not aware of such a thing in core. I think this is part of Examples module.

jwilson3’s picture

Wow, cant believe I mistook this for core. Thanks for setting me straight!

rfay’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev

And hoping to get a patch from you :-)

jwilson3’s picture

Status: Active » Needs review
FileSize
1.89 KB

You bet.

rfay’s picture

Status: Needs review » Needs work

Thanks for the great work on this. Just a couple of nits.

+++ b/theming_example/theming-example-text-form.tpl.phpundefined
@@ -0,0 +1,17 @@
+ * Template file for theming_example_text_form
+ *

You don't want this to have underscores here either do you?

+++ b/theming_example/theming_example.moduleundefined
+++ b/theming_example/theming_example.moduleundefined
@@ -78,7 +78,7 @@ function theming_example_theme() {

@@ -78,7 +78,7 @@ function theming_example_theme() {
       'render element' => 'form',
       // In this one the rendering will be done by a tpl.php file instead of
       // being rendered by a function, so we specify a template.
-      'template' => 'theming_example_text_form',
+      'template' => 'theming-example-text-form',
     ),
   );

Since this is obviously very important, it may be good to explain here why one must never use underscores.

jwilson3’s picture

Good points. I've generally cleaned up the comments around this specific feature (see the interdiff to see exactly what was added).

Mile23’s picture

Status: Needs work » Fixed

I'm pretty sure this patch didn't automatically test itself because it ends in 6.

Thanks, jwilson3. :-)

Committed: http://drupalcode.org/project/examples.git/commitdiff/b5f2b4db95c90bf25d...

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

Anonymous’s picture

Issue summary: View changes

Updated to reflect reality