Coder Social home page Coder Social logo

softmoth / raku-template-mustache Goto Github PK

View Code? Open in Web Editor NEW
21.0 5.0 19.0 161 KB

Raku library for the Mustache template format

Home Page: https://modules.raku.org/dist/Template::Mustache:cpan:SOFTMOTH

License: Artistic License 2.0

MAXScript 0.04% Raku 98.16% Mustache 1.81%
mustache-implementations mustache raku

raku-template-mustache's Issues

Fails to install on windows

Running Windows 11 in virtual box. Getting this report when trying to install:

$ zef install Template::Mustache
===> Searching for: Template::Mustache
Aborting due to test failure: Template::Mustache:ver<1.2.3>:auth<github:softmoth> (use --force-test to override)
===> Testing: Template::Mustache:ver<1.2.3>:auth<github:softmoth>
[Template::Mustache] ===SORRY!=== Error while compiling C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3/t\91-specs.t
[Template::Mustache] ===SORRY!=== Error while compiling C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3\t\lib\Template\Mustache\TestUtil.rakumod (Template::Mustache::TestUtil)
[Template::Mustache] Failed to open file C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3\t\lib\.precomp\BE04B1FADFC312E3411CB403B43E629B7AED3ADC\C1\C1DA909DAD9BF713751A74EBF038C545A1EA6ECC.repo-id.EE828FO93FBR6GJHQ0TYDV5O5.tmp: No such file or directory
[Template::Mustache] at C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3\t\lib\Template\Mustache\TestUtil.rakumod (Template::Mustache::TestUtil):4
[Template::Mustache] Actually thrown at:
[Template::Mustache]   in any statement_control at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache]   in any routine_declarator:sym<sub> at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache]   in any routine_declarator at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache]   in any term:sym<routine_declarator> at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache]   in any term at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache] at C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3/t\91-specs.t:5
[Template::Mustache] ===SORRY!=== Error while compiling C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3/t\92-specs-file.t
[Template::Mustache] ===SORRY!=== Error while compiling C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3\t\lib\Template\Mustache\TestUtil.rakumod (Template::Mustache::TestUtil)
[Template::Mustache] Failed to open file C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3\t\lib\.precomp\BE04B1FADFC312E3411CB403B43E629B7AED3ADC\C1\C1DA909DAD9BF713751A74EBF038C545A1EA6ECC.repo-id.BLPGERHM2C1TZGFUT4TD8D7ST.tmp: No such file or directory
[Template::Mustache] at C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3\t\lib\Template\Mustache\TestUtil.rakumod (Template::Mustache::TestUtil):4
[Template::Mustache] Actually thrown at:
[Template::Mustache]   in any statement_control at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache]   in any routine_declarator:sym<sub> at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache]   in any routine_declarator at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache]   in any term:sym<routine_declarator> at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache]   in any term at C:\Program Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
[Template::Mustache] at C:\Users\sdond\.zef\tmp\Template%3A%3AMustache%3Aver%3C1.2.3%3E%3Aauth%3Ccpan%3ASOFTMOTH%3E.tar.gz\Template-Mustache-1.2.3/t\92-specs-file.t:5
===> Testing [FAIL]: Template::Mustache:ver<1.2.3>:auth<github:softmoth>

Tests fail on current rakudo

$ perl6-m --version
This is perl6 version 2015.04-45-gecd3159 built on MoarVM version 2015.04-20-g10f3ad3

A panda install Task::Star fails with

==> Building Template::Mustache
Compiling lib/Template/Mustache.pm to mbc
==> Testing Template::Mustache
t/01-basic.t ....... ok
t/02-file.t ........ ok
t/03-cascade.t ..... ok
t/04-lambda.t ...... ok
t/10-objects.t ..... ok
t/50-readme.t ...... ok
Failed to get the directory contents of '/home/moritz/.panda-work/1429944310_14/../mustache-spec/specs': chdir failed: Unknown system error
  in method dir at src/gen/m-CORE.setting:18969
  in sub dir at src/gen/m-CORE.setting:19288
  in sub load-specs at t/91-specs.t:26
  in block <unit> at t/91-specs.t:5
t/91-specs.t ....... 
No subtests run 
Failed to get the directory contents of '/home/moritz/.panda-work/1429944310_14/../mustache-spec/specs': chdir failed: Unknown system error
  in method dir at src/gen/m-CORE.setting:18969
  in sub dir at src/gen/m-CORE.setting:19288
  in sub load-specs at t/92-specs-file.t:42
  in block <unit> at t/92-specs-file.t:16
t/92-specs-file.t .. 
No subtests run 
Test Summary Report
-------------------
t/91-specs.t     (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
t/92-specs-file.t (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
Files=8, Tests=25, 26 wallclock secs ( 0.07 usr  0.02 sys + 21.58 cusr  0.98 csys = 22.65 CPU)
Result: FAIL

deprecation warning

rakudo-star-2015.07/install/bin/perl6-m --target=mbc --output=rakudo-star-2015.07/install/share/perl6/lib/Template/Mustache.pm.moarvm rakudo-star-2015.07/install/share/perl6/lib/Template/Mustache.pm
Saw 1 occurrence of deprecated code.

$_PROGRAM_NAME seen at:
rakudo-star-2015.07/install/share/perl6/lib/Template/Mustache.pm, line 184
Deprecated since v2015.6, will be removed with release v2015.9!
Please use $_PROGRAM-NAME instead.

Please contact the author to have these occurrences of deprecated code
adapted, so that this message will disappear!

Please note that ALL deprecated features will be removed at the RC-0 release
(expected September 2015).

Test fails on Windows as of 2016.11

===> Testing: Template::Mustache:auth('github:softmoth')
# Reading spec files from '../mustache-spec/specs'
read from dirhandle failed: 3
  in sub load-specs at C:\Users\steve\star\rakudo-star-2016.12.zef\modules\p6-Template-Mustache\t\lib\Template\Mustache\TestUtil.pm (Template::Mustache::TestUtil) line 11
  in block <unit> at t/91-specs.t line 8

# Reading spec files from '../mustache-spec/specs'
read from dirhandle failed: 3
  in sub load-specs at C:\Users\steve\star\rakudo-star-2016.12.zef\modules\p6-Template-Mustache\t\lib\Template\Mustache\TestUtil.pm (Template::Mustache::TestUtil) line 11
  in block <unit> at t/92-specs-file.t line 19

===> Testing [FAIL]: Template::Mustache:auth('github:softmoth')

Template::Mustache fails to install/recognize dependencies

Using zef to install Template::Mustache (a dependency of p6doc) fails tests, reporting missing dependencies which have been downloaded and built, but not yet installed. Using a fresh install on linux, perl6 2018.12.

doug@ender:~$ zef install --install-to=/var/local/test/share/perl6/site URI Template::Mustache
===> Searching for: URI, Template::Mustache
===> Testing: Template::Mustache:ver<1.0.1>:auth<github:softmoth>
# Reading spec files from 't/specs'
# - t/specs/comments.json: 11
# - t/specs/delimiters.json: 14
# - t/specs/interpolation.json: 31
# - t/specs/inverted.json: 21
# - t/specs/partials.json: 11
# - t/specs/sections.json: 26
# - t/specs/~lambdas.json: 10
# Reading spec files from 't/specs'
# - t/specs/comments.json: 11
# - t/specs/delimiters.json: 14
# - t/specs/interpolation.json: 31
# - t/specs/inverted.json: 21
# - t/specs/partials.json: 11
# - t/specs/sections.json: 26
# - t/specs/~lambdas.json: 10
===SORRY!===
Could not find URI at line 70 in:
    /home/doug/.zef/store/p6-Template-Mustache.git/d84fdf303480622805de119024e930c05c9fd6d2/lib
    /home/doug/.zef/store/p6-Template-Mustache.git/d84fdf303480622805de119024e930c05c9fd6d2
    /home/doug/.perl6/lib
    /home/doug/.perl6
    /var/local/test/share/perl6/site
    /var/local/test/share/perl6/vendor
    /var/local/test/share/perl6
    CompUnit::Repository::AbsolutePath<73193568>
    CompUnit::Repository::NQP<47742528>
    CompUnit::Repository::Perl5<47742568>
===> Testing [FAIL]: Template::Mustache:ver<1.0.1>:auth<github:softmoth>
Aborting due to test failure: Template::Mustache:ver<1.0.1>:auth<github:softmoth> (use --force-test to override)

The digit 0 doesn't print

Hi @softmoth,

Context variables with an assigned value of the number 0 render blank:

use Template::Mustache;

Template::Mustache.render('Zero: "{{ zero }}"', { zero => 0 }).say; # Zero: ""
Template::Mustache.render('One: "{{ one }}"', { one => 1 }).say;   # One: "1"

The string '0' prints fine.

Thanks,
Sam

Failing to install with Rakudo master

Here's the error

[Template::Mustache] This type cannot unbox to a native string: P6opaque, Int
[Template::Mustache]   in sub parse-template at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 250
[Template::Mustache]   in sub resolve at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 278
[Template::Mustache]   in block  at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 312
[Template::Mustache]   in sub get at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 308
[Template::Mustache]   in sub format at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 342
[Template::Mustache]   in sub format at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 271
[Template::Mustache]   in method render at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 208
[Template::Mustache]   in block <unit> at t/91-specs.t line 8
[Template::Mustache] # You planned 125 tests, but ran 118
[Template::Mustache] This type cannot unbox to a native string: P6opaque, Int
[Template::Mustache]   in sub parse-template at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 250
[Template::Mustache]   in sub resolve at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 278
[Template::Mustache]   in block  at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 312
[Template::Mustache]   in sub get at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 308
[Template::Mustache]   in sub format at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 342
[Template::Mustache]   in sub format at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 271
[Template::Mustache]   in method render at /home/jmerelo/.zef/store/Template-Mustache-1.1.4.tar.gz/Template-Mustache-1.1.4/lib/Template/Mustache.rakumod (Template::Mustache) line 208
[Template::Mustache]   in block <unit> at t/92-specs-file.t line 27
[Template::Mustache] # You planned 125 tests, but ran 118

Doubt about Mustache specification

Hi, right now unused variables are replaced by an empty string:

use Template::Mustache;
Template::Mustache.render('{{bar}} {{foo}}', {foo=>"d"}) # will print ' d'

Is there a way to disable this? Or is not possible? It would be extremely helpful to concatenate renders without replacing all variables at the same time.

Inheritance templates

Will this feature be implemented in the near future? It would be handy for Documentable.

Allow HTML escaping to be disabled

Hi,

I am interpolating JSON into a mustache template and the quoted field names of the JSON object are being HTML escaped.

Data being passed to the template:

[
  {
    "x": 1599160499999,
    "text": "entry: 53.13 stop: 52.86435",
    "title": "ENTRY"
  }
]

Template:

{
        type : 'flags',
        data : {{signals}},
        onSeries : 'candlestick',
        shape : 'flag'
},

Generated to my HTML/JavaScript on disk:

data : [
  {
    &quot;x&quot;: 1599160499999,
    &quot;text&quot;: &quot;entry: 53.13 stop: 52.86435&quot;,
    &quot;title&quot;: &quot;ENTRY&quot;
  }
]

When I pass this data into the template, it would be great if I could "disable" escaping. EG mark this html contect as "safe"
Perhaps something like:

my $html = $stache.render('highchart-candlestick', {
    signals => ( :content( to-json(@signal-series) ), :html-safe(True) )
});

Note: to-json being used from JSON::Fast

Not working after glr merge

Output of: pre-glr-debug.sh t/01-basic.t
Work in progress: https://github.com/mj41/p6-Template-Mustache/commits/mj-fix-glr

====================================================================================
origin  [email protected]:mj41/p6-Template-Mustache.git (fetch)
origin  [email protected]:mj41/p6-Template-Mustache.git (push)
up  [email protected]:softmoth/p6-Template-Mustache.git (fetch)
up  [email protected]:softmoth/p6-Template-Mustache.git (push)
====================================================================================
Output of 'git log -1 ; git diff HEAD~1':
commit b68f6819433fc25a338453f22a68b8b49ae0c4dd
Author: Michal Jurosz 
Date:   Sat Sep 5 15:41:41 2015 +0200

    !!! debug
diff --git a/lib/Template/Mustache.pm b/lib/Template/Mustache.pm
index 6b80083..1bb29e6 100644
--- a/lib/Template/Mustache.pm
+++ b/lib/Template/Mustache.pm
@@ -44,10 +44,12 @@ class Template::Mustache {
 
     class Template::Mustache::Actions {
         method TOP($/) {
+            note $/.perl;
             my %x = :val(''), :contents([]);
             my @frames;
             @frames.unshift: $%x;
             for $».made.flat -> $hunk {
+                note $hunk.perl;
                 if $hunk ~~ Associative and $hunk eq 'section' {
                     if $hunk {
                         @frames[0].push: $hunk;
@@ -78,7 +80,6 @@ class Template::Mustache {
                 }
             }
             @frames[0].push(~$0) if $0.chars;
-
             make %x;
         }
         method hunk($/) {
@@ -176,6 +177,7 @@ class Template::Mustache {
 
         my $actions = Template::Mustache::Actions.new;
         my @parsed = parse-template($initial-template);
+        note @parsed.perl; exit; # mj41 debug
         return format(@parsed, [%context]);
 
 
====================================================================================

====================================================================================
Switching perl6 to pre GLR (rakudo pre-glr tag)
Switching to moar-pre-glr
Updating shims
====================================================================================
Match.new(ast => Any, list => (Match.new(ast => Any, list => (), hash => EnumMap.new(), orig => "  \{\{string}}\n", to => 13, from => 12),), hash => EnumMap.new(:hunk([Match.new(ast => ["  ", {:type("var"), :val("string")}]<>, list => (Match.new(ast => Any, list => (), hash => EnumMap.new(), orig => "  \{\{string}}\n", to => 2, from => 0),), hash => EnumMap.new(:tag(Match.new(ast => {:type("var"), :val("string")}, list => (), hash => EnumMap.new(:name(Match.new(ast => "string", list => (), hash => EnumMap.new(:ident([Match.new(ast => Any, list => (), hash => EnumMap.new(), orig => "  \{\{string}}\n", to => 10, from => 4)])), orig => "  \{\{string}}\n", to => 10, from => 4))), orig => "  \{\{string}}\n", to => 12, from => 2))), orig => "  \{\{string}}\n", to => 12, from => 0)])), orig => "  \{\{string}}\n", to => 13, from => 0)
"  "
{:type("var"), :val("string")}
["  ", {:type("var"), :val("string")}, "\n"]<>
====================================================================================

====================================================================================
Switching perl6 to post GLR (rakudo nom branch)
Switching to moar-nom
Updating shims
====================================================================================
Match.new(ast => Any, list => (Match.new(ast => Any, list => (), hash => EnumMap.new(), orig => "  \{\{string}}\n", to => 13, from => 0)), hash => EnumMap.new(:hunk($[])), orig => "  \{\{string}}\n", to => 13, from => 0)
["  \{\{string}}\n"]
====================================================================================

Template Mustache is test fails while installing Bailador

Hi,

Recently got this error when install Bailador on 2017.06 and 2017.07.

Please see below ...

===> Testing [OK] for Template::Mojo:ver('0.1')
===> Testing: Template::Mustache:auth('github:softmoth')

Failed test 'Inline partial can get filesystem partial'

at t/03-cascade.t line 56

expected: 'Say Hello, Jimmy.

, and find me a Hello, Jimmy.

'

got: 'Say , and find me a '

Looks like you failed 1 test of 5

Reading spec files from '../mustache-spec/specs'

Reading spec files from '../mustache-spec/specs'

===> Testing [FAIL]: Template::Mustache:auth('github:softmoth')
Aborting due to test failure: Template::Mustache:auth('github:softmoth') (use --force-test to override)

Tag names can only contain what is considered an <ident>

Because of this tags containing dashes (and other non <ident> characters)
will not be substituted, as can be seen here:

> perl6 -e 'use Template::Mustache; Template::Mustache.render(\'{{base00-hex}}\', { \'base00-hex\' => 1 }).say'
# OUTPUT: «{{base00-hex}}␤»

The spec leaves this point somewhat open,
but the discussion in mustache/spec#67 suggests that it can basically contain anything
that isn't interpreted in some other way (minus whitespace).

The way I see it the following token, and possibly ones using it, would need to be changed.
https://github.com/softmoth/p6-Template-Mustache/blob/5ad705e3b2e30fbc1cb9ae6590c49c7db7b51167/lib/Template/Mustache.pm#L31

Weird ordering in rendered output

Hello, I am seeing weird ordering on the rendered output when I provide the following as context to .render:

#!/usr/bin/env perl6

use v6;

use Template::Mustache;

my %h = categories => [
    category_pages => [
       {title => "Perl 6",
        url   => "https://www.perl6.org"},
       {title => "Perl 6 Modules",
        url   => "https://modules.perl6.org"}],
    title => "General tasks"];


my $html = q:to/EOF/;
{{#categories}}
{{ title }} <!-- should be first item -->
{{#category_pages}}
{{ title }} : {{ url }}</br>
{{/category_pages}}
{{/categories}}
EOF

say Template::Mustache.render: $html, %h;

# Output
#
# <!-- should be first item -->
# Perl 6 : https://www.perl6.org</br>
# Perl 6 Modules : https://modules.perl6.org</br>
# General tasks <!-- should be first item -->

Content of section tags spills out

Perl 6 code snippet:

use Template::Mustache;

my $template = q:to/END/;
<!doctype html>
<html lang="{{ lang }}">
  <head>
    <title>{{ title }}</title>
    <meta charset="UTF-8" />
    {{#css}}
        {{#css}}
        <link rel="stylesheet" href="{{.}}">
        {{css}}
    {{/css}}
  </head>

    <body>
        <div id="___top"></div>

        {{#title}}<h1 class='title'>{{ title }}</h1>{{/title}}
        {{#subtitle}}<p class='subtitle'>{{ subtitle }}</p>{{/subtitle}}

        <div class="content">
        {{#body}}
            {{{ . }}}
        {{/body}}
        </div>
    </body>

</html>
END

my %page = %(
    lang => 'English',
    title => 'New page',
    subtitle => 'From first to last',
    css => ["./github.css"],
    body => [
        "<h1>First heading</h1>",
        '<pre><code>my &sum = -> $x, $y { $x + $y }</code></pre>'
    ],
);

my $output-html = Template::Mustache.render($template, %page);
say $output-html;

Output HTML:

<!doctype html>
<html lang="English">
  <head>
    <title>New page</title>
    <meta charset="UTF-8" />
        <link rel="stylesheet" href="./github.css">
        ./github.css
  </head>

  <body>
      <div id="___top"></div>
      <h1 class='title'>New page</h1>
      <p class='subtitle'>From first to last</p>

      <div class="content">
          <h1>First heading</h1>
          <pre><code>my &sum = -> $x, $y { $x + $y }</code></pre>
      </div>
  </body>

</html>

As you can see, although the CSS filepath was properly included in the {{#css}} ...{{css}} tag, there's also another copy of it hanging out of place in the head section, which ends up showing in the rendered HTML:

image

Speed problems

Hi, first of all, thanks for your work @softmoth. After updating documentable to use Mustache templates, I have noticed a huge increase in the execution time of documentable. In the previous versions (without templates), generate the documentation would take no more than 6-10 minutes. After using templates, this is the time it takes:

[=======================================================================]100.00%
Generate source files has taken 785.1736876 seconds 
Generating Kind::Syntax files 👇 ...
[=======================================================================]100.00%
Generating Kind::Routine files 👇 ...
[=======================================================================]100.00%
Generating per kind files has taken 957.6732023 seconds 
Generating indexes...
Generating index files has taken 35.87684523 seconds 
Writing search file...
Generating entries
Writing all generated files 🙌 ...
[#######################################################################]100.00%
Writing generated files has taken 1.99796244 seconds 
Whole process has taken 2067.5031522 seconds

Around 30 minutes. This problem was also found by @finanalyst when he tried to remake the Pod::To::HTML module.

I don't know if this is the usual time any other implementation of Mustache (in a different language) would take to do the same. Any ideas on how to solve this?

Crash when parallel render; not thread safe? Dies with X::HyperRace::Died in test case

The benchmarking test case in t/11-iterables.t is failing:

An operation first awaited:
  in block  at t/11-iterable.t line 71
  in block <unit> at t/11-iterable.t line 38

Died with the exception:
    A worker in a parallel iteration (hyper or race) initiated here:
      in block  at lib/Template/Mustache.rakumod (Template::Mustache) line 577
      in block  at lib/Template/Mustache.rakumod (Template::Mustache) line 566
      in sub format at lib/Template/Mustache.rakumod (Template::Mustache) line 537
      in sub format at lib/Template/Mustache.rakumod (Template::Mustache) line 397
      in sub format at lib/Template/Mustache.rakumod (Template::Mustache) line 397
      in method render at lib/Template/Mustache.rakumod (Template::Mustache) line 295
      in block  at t/11-iterable.t line 57

    Died at:
        Cannot invoke this object (REPR: Uninstantiable; Callable)

Unfortunately this was not caught because the test case is run only when TEST_BENCHMARK=1 (or TEST_ALL=1). While that is set on the Travis CI runs, there aren't enough CPU cores when running there to run the test. So I am not sure when this started failing.

At line 577 of Template/Mustache.rakudoc it essentially calls .map(&format_section).join. There may be some shared state happening inside the format() routine that could be pulled out to outside of the map, if that is what's needed.

The test case is complicated, and of course the rendering function itself is very complex, so it may take some time to get an isolated test case for this issue. And I don't have a lot of experience with hyper/race handling. Any suggestions or links to relevant docs are very welcome!

Cannot install Template::Mustache with rakudo 2019.11

❯ raku -v
This is Rakudo version 2019.11 built on MoarVM version 2019.11
implementing Perl 6.d.

❯ zef install --/test Template::Mustache
===> Searching for: Template::Mustache
===> Installing: Template::Mustache:ver<1.2.1>:auth<github:softmoth>
===> Install [FAIL] for Template::Mustache:ver<1.2.1>:auth<github:softmoth>: ===SORRY!=== Error while compiling /Users/skaji/try/20200719/site#sources/79E3FB3E714BBAD29F62C6D49C2D17898903B5B7 (Template::Mustache)
Confused
at /Users/skaji/try/20200719/site#sources/79E3FB3E714BBAD29F62C6D49C2D17898903B5B7 (Template::Mustache):150
------>                             &.log:⏏ :level<Trace>, "*****", $f.raku;
    expecting any of:
        colon pair

===SORRY!=== Error while compiling /Users/skaji/try/20200719/site#sources/79E3FB3E714BBAD29F62C6D49C2D17898903B5B7 (Template::Mustache)
Confused
at /Users/skaji/try/20200719/site#sources/79E3FB3E714BBAD29F62C6D49C2D17898903B5B7 (Template::Mustache):150
------>                             &.log:⏏ :level<Trace>, "*****", $f.raku;
    expecting any of:
        colon pair

If Template::Mustache does not support rakudo 2019.11 intentionally, feel free to close this issue.

Build fails on Rakudo 2017.3-232-gfbc6697

$ perl6 --version
This is Rakudo version 2017.03-232-gfbc6697 built on MoarVM version 2017.03-128-gc9ab59c
===> Testing: Template::Mustache:auth('github:softmoth')
t/01-basic.t ....... ok
t/02-file.t ........ ok
t/03-cascade.t .....1/5
# Failed test 'Inline partial can get filesystem partial'
# at t/03-cascade.t line 56
# expected: 'Say Hello, Jimmy.
# , and find me a Hello, Jimmy.
# '
#      got: 'Say , and find me a '
# Looks like you failed 1 test of 5
t/03-cascade.t ..... Failed 1/5 subtests 
t/04-lambda.t ...... ok
t/05-promise.t ..... ok
t/10-objects.t ..... ok
t/50-readme.t ...... ok
# Reading spec files from '../mustache-spec/specs'
t/91-specs.t ....... ok
# Reading spec files from '../mustache-spec/specs'
t/92-specs-file.t .. ok
Test Summary Report
-------------------
t/03-cascade.t  (Wstat: 0 Tests: 5 Failed: 1)
  Failed tests:  5
Files=9, Tests=28,  5 wallclock secs
Result: FAILED
===> Testing [FAIL]: Template::Mustache:auth('github:softmoth')

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.