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

Template::AutoFilter engine #1545

Closed
incognico opened this issue May 12, 2020 · 1 comment
Closed

Template::AutoFilter engine #1545

incognico opened this issue May 12, 2020 · 1 comment
Labels
Enhancement Won't Fix For various reasons, won't fix this issue/apply this PR.

Comments

@incognico
Copy link

Would it be possible to add Template::AutoFilter as Template engine?

I've amateurishly hacked together a working module (template: "template_autoFilter"), attached below but as AutoFilter itself just abstracts from Template::Toolkit that's probably overkill. Maybe TemplateToolkit.pm could detect $tt_config{'AUTO_FILTER'}, and if it exists just require Template::AutoFilter and use that one if installed.

For just HTML entity encoding Template::AutoFilter has a few advantages over the Template::Stash::AutoEscaping example in the pod, for example it allows the "none" filter plus a few other things. It was also mentioned in #1368

Looking forward to see this officially supported in one way or another.

--- TemplateToolkit.pm  2020-05-12 12:44:07.883241301 +0200
+++ TemplateAutoFilter.pm  2020-05-12 12:47:28.923173917 +0200
@@ -1,13 +1,13 @@
-# ABSTRACT: Template toolkit engine for Dancer2
+# ABSTRACT: Template::AutoFilter toolkit engine for Dancer2

-package Dancer2::Template::TemplateToolkit;
-$Dancer2::Template::TemplateToolkit::VERSION = '0.300003';
+package Dancer2::Template::TemplateAutoFilter;
+$Dancer2::Template::TemplateAutoFilter::VERSION = '0.300003';
 use Moo;
 use Carp qw<croak>;
 use Dancer2::Core::Types;
 use Dancer2::FileUtils qw<path>;
 use Scalar::Util ();
-use Template;
+use Template::AutoFilter;

 with 'Dancer2::Core::Role::Template';

@@ -37,7 +37,7 @@
         sub { [ $ttt->views ] },
     ];

-    my $tt = Template->new(%tt_config);
+    my $tt = Template::AutoFilter->new(%tt_config);
     $Template::Stash::PRIVATE = undef if $self->config->{show_private_variables};
     return $tt;
 }
@cromedome cromedome added the Won't Fix For various reasons, won't fix this issue/apply this PR. label May 8, 2022
@cromedome
Copy link
Contributor

Hi @incognico,

I would very much like to see this released as a plugin for Dancer2. I am not, however, supportive of seeing another template engine added to the core of Dancer2. Having another template engine adds another prereq for Dancer2, and one that not everyone will want to use. On a side note, we're actually on the verge of removing another template engine from core altogether (one we wrote, in fact!).

Is there something we can do to assist you in releasing this as a plugin? Let me know and I'd be happy to help!

Thanks for the idea :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Won't Fix For various reasons, won't fix this issue/apply this PR.
Projects
None yet
Development

No branches or pull requests

2 participants