views do NOT use TT2's INCLUDE_PATH directive#1037
Closed
Conversation
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.
Contributor
|
👍 |
Member
|
👍 Merge away. |
Member
Author
|
Merged as 3224d52. Thanks all! |
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)
Member
|
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. I'm not sure but I think PR #955 may have been a better solution? |
Member
Contributor
|
Moving discussion to #1093 |
Merged
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.