Giter Site home page Giter Site logo

text-caml's People

Contributors

arodland avatar fco avatar igor-lobanov avatar kaoru avatar mivanchenko avatar nowox avatar ovirs avatar skaji avatar und3f avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

text-caml's Issues

Sections remove traling line breaks

The following code removes the trailing line break after the section:

my $view = Text::Caml->new;
print $view->render_file('template', { abc => "Test" }) . "\n";

Template:

{{#abc}}
  This is a test.
{{/abc}}
ABC

The output is This is a test.ABC.
I would have expected a new line before ABC.
Am I wrong?

Thanks!

Cannot set templates path via constructor

It does not seem to be possible to set the template path via the constructor. In line 36+37 the expression after unless may be incorrect:
currently:

$self->set_templates_path('.')
  unless $self->templates_path;

but should be:

$self->set_templates_path('.')
  unless $self->{templates_path};

i.e. the curly braces are missing. The workaround is of course to use the method set_template_path on the constructed object.

Iterating over hash keys

Let's consider the hash my %hash = ( foo => { a => 42, b => 43, c => 44 } );

It would be interesting to implement something that allows to iterate over hash keys

{{#hash.keys}}
    {{.}}
{{/hash}}

In case of more complex data we can still imaging using the same kind of syntax:

{{#hash.keys}}
    {{.}} {{name}} {{genre}}
{{/hash.keys}}

Or even a full nested hash support:

{{#animals.keys}}
    {{.}}:
    {{#mammal.keys}} 
        {{.}} -> {{name}}
    {{/mammal.keys
{{/hash.keys}}

What do you think?

Configurable default behaviour of HTML escaping

What do you think about adding configuration option to set default behavior as non-escaping? Some templates are used in HTML documents and current behavior is appropriate. But sometimes it's required to use templates for other types of documents.

'&' usage of course solves this issue but making non-escaping behavior default for such cases looks more handy.

my $view = Text::Caml->new(do_no_escape => 1);

'&' can be switcher in this case:

    my $do_not_escape = $self->{do_not_escape};
    if ($tag =~ s/\A \&//xms) {
        $do_not_escape = !$do_not_escape;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.