Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

views do NOT use TT2's INCLUDE_PATH directive #1037

Closed
wants to merge 4 commits into from

Conversation

veryrusty
Copy link
Member

Previously we were (usually) passing absolute paths for templates (and have ABSOLUTE => 1 set) when rendering output with TemplateToolkit, which worked for most use-cases.

However, as reported in #951 (with further discussion on IRC), if you set a path 'fragment' for a view, such as

  set views => 'foobar';

The both Dancer2::Template::TemplateToolkit and TT2's code for handling multiple INCLUDE_PATHs were both concatenating the views directory with the template name to be rendered. (i.e. looking for a template like foobar/foobar/index.tt).

Alternate (and simpler) approach to solve #951 (and PR #955) - don't set INCLUDE_PATH and let D2 to the path concatenation.

Data::Dumper is not used in D2::Core::Role::Template.
Previously we were (typically) passing absolute paths to templates
(the ABSOLUTE flag is true in the default tt2 config) which worked in
most cases. However, setting 'views' to a path that was not absolute
would cause our TemplateToolkit wrapper to concatenate the views path
and the tempalte name, pass that to TT2 which would try and do exactly
the same. This resulted in templates not being found.

Instead we no longer set TT2's INC_PATH directive, which stops the
double-up of the path concatenation. Ref. #951
Ensure `views` setting can be either an absolute or relative path.
@cromedome
Copy link
Contributor

👍

@xsawyerx
Copy link
Member

👍

Merge away.

@veryrusty
Copy link
Member Author

Merged as 3224d52. Thanks all!

@veryrusty veryrusty closed this Oct 22, 2015
@veryrusty veryrusty deleted the feature/no_tt_inc_path branch October 22, 2015 12:47
xsawyerx added a commit that referenced this pull request Dec 16, 2015
    [ DOCUMENTATION ]
    * Update core team members and contributors list. (Russell Jenkins)
    * GH #1066: Fix typo in Cookbook. (gertvanoss)
    * Correct typo. It's "query_parameters", not "request_parameters".
      Thanks to mst for letting me know and making sure I fix it!
      (Sawyer X)

    [ BUG FIXES ]
    * GH #1040: Forward with a post body no longer tries to re-read body
      filehandle. (Bas Bloemsaat)
    * GH #1042: Add Diggest::SHA as explicit prequisite for installs on
      perl < v5.9.3. (Russell Jenkins)
    * GH #1071, #1070: HTML escape the message in the default error page.
      (Peter Mottram)
    * GH #1062, #1063: Command line interface didn't support
      "-s SKELETON_DIRECTORY" in any order.
      (Nuno Carvalho)
    * GH #1052, #1053: Always call before_serializer hook when serializer
      is set.
      (Mickey Nasriachi)
    * GH #1034: Correctly use different session cookie name for Dancer2.
      (Jason A. Crome)
    * GH #1060: Remove trailing slashes when providing skeleton
      directory.
      (Gabor Szabo)

    [ ENHANCEMENTS ]
    * Use Plack 1.0035 to make sure you only have HTTP::Headers::Fast
      in the Plack::Request object internally.
    * GH #951 #1037: Dancer2::Template::TemplateToolkit no longer sets TT2
      INCLUDE_PATH directive, allowing `views` setting to be non-absolute
      paths. (Russell Jenkins)
    * GH #1032 #1043: Add .dancer file to new app scaffolding.
      (Jason A. Crome)
    * GH #1045: Small cleanups to Request class. (Russell Jenkins)
    * GH #1033: strict && warnings in Dancer2::CLI. (Mohammad S Anwar)
    * GH #1052, #1053: Allow before_serializer hook to change the content
      using @_.
      (Mickey Nasriachi)
    * GH #1060: Ignore .git directory when using an external skeleton
      directory.
      (Gabor Szabo)
    * GH #1060: Support more asset file extensions. (Gabor Szabo)
    * GH #1072: Add request->is_options(). (Theo van Hoesel)
@bigpresh
Copy link
Member

bigpresh commented Jan 6, 2016

I'm very late to this, but I think this may have been a mistake - I think it would be more user-friendly to let TT2 deal with it. If I'm not mistaken, this means that all apps that used e.g. views => 'views' then expected that process foo.tt would load $appdir/views/foo.tt, and that a [% PROCESS 'bar.tt' %] within 'foo.tt would load $appdir/views/bar.tt, would now need changing, as they wouldn't work after this change?

I'm not sure but I think PR #955 may have been a better solution?

@xsawyerx
Copy link
Member

xsawyerx commented Jan 6, 2016

@bigpresh can you please open a new issue and reply to #1093 with it?

This issue is closed and no one is monitoring it, I think.

@abeverley
Copy link
Contributor

Moving discussion to #1093

@veryrusty veryrusty mentioned this pull request Jan 9, 2016
xsawyerx added a commit that referenced this pull request Jan 12, 2016
    [ BUG FIXES ]
    * GH #1013, #1092: Remove race condition caused by caching available
      engines. (Sawyer X, Menno Blom, Russell Jenkins)
    * GH #1089: Exact macthing of route regex comments for tokens/splats.
      (Sawyer X)
    * GH #1079, #1082: Allow routes to return '0' as response content,
      and serializer hooks are called when default response content is
      to be returned. (Alberto Simões, Russell Jenkins)
    * GH #1093, 1095: Use a dynamic TT2 INCLUDE_PATH to allow relative
      views with relative includes; fixing regression introduced by #1037.
      (Russell Jenkins)
    * GH #1096, #1097: Return compatibility on Perl 5.8.x!
      (Peter Mottram - @SysPete)

    [ DOCUMENTATION ]
    * GH #1076: Typo in Dancer2::Core::Hook POD. (Jonathan Scott Duff)

    [ ENHANCEMENTS ]
    * GH #1074: Add sample session engine config to skeleton app.
      (Peter Mottram - @SysPete)
    * GH #1088: Return route objects when defining new routes.
      (Sawyer X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants