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

Remove indenting within compiled templates #29

Merged
merged 1 commit into from
Jan 8, 2014
Merged

Remove indenting within compiled templates #29

merged 1 commit into from
Jan 8, 2014

Conversation

dracos
Copy link
Contributor

@dracos dracos commented Sep 4, 2013

If a template contains a multiline string, within for example a call to a Locale::gettext template function for translation, then the compiled version of the string written to the compiled template file will contain extra indent whitespace due to the regular expressions within the as_perl() function. For example, the template fragment:

[% loc("This is a
multiline string.") %]

will be written to the compiled file as something like (note indentation):

Template::Document->new({
...
    BLOCK => sub {
...
        eval { BLOCK: {
...
    $output .=  $stash->get(['loc', [ 'This is a
    multiline string.' ]]);

This means that - once a compiled template is loaded in, after say a server restart - the translation stops working because the original string does not exactly match the translation string.

The indentation appears to be optional, and is only within compiled template files, so this commit simply removes it.

If a template contains a multiline string, within for example a call to
a Locale::gettext template function for translation, then the compiled
version of the string written to the compiled template file will contain
extra indent whitespace due to the regular expressions within the
as_perl() function. For example, the template fragment:

[% loc("This is a
multiline string.") %]

will be written to the compiled file as something like

    $output .=  $stash->get(['loc', [ 'This is a
    multiline string.' ]]);

This means that - once a compiled template is loaded in, after say a
server restart - the translation stops working because the original
string does not exactly match the translation string.

The indentation appears to be optional, and is only within compiled
template files, so this commit simply removes it.
abw added a commit that referenced this pull request Jan 8, 2014
Remove indenting within compiled templates
@abw abw merged commit 34138b4 into abw:master Jan 8, 2014
djzort pushed a commit to openlocal/fixmystreet that referenced this pull request Apr 3, 2014
Embed a local copy of Template::Document, which includes the change
of abw/Template2#29 so that multiline
quoted strings within a template are not indented and thus stop
translating.
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.

None yet

2 participants