Looking for template engine like HTML::Mason (or Mason), so what "compiles" source components into perl code, but instead of perl-code will "compile" components into JavaScript code and after run/execute them with Javascript::V8 perl module.
Motivation: Looking for solution for safe template language, what can edit users without compromising the server security. JavaScript is full featured language so using it is probably better/faster than some "mini languages" like TT or similar. The best for me would be an extension (rewrite) of Mason for compiling into Joose/JavaScript instead of Moose/Perl. ;)
And yes, want do this from perl with Javascript::V8 because this way is possible having all perl's power available via Javascript::V8 $context->bind_function in very safe way.
Questions:
- Anyone know something like? (found nothing in CPAN)...
EDIT: in Mason you can write for example
% #perl version
% my(@list) = qw(Jane John Doe);
<ul>
% foreach my $item (@list) {
<li><% uc($item) %></li>
% }
</ul>
would be nice to have possibility write the above in JS, like:
% //javascript version
% var list = ["Jane", "John", "Doe"];
<ul>
% for(var i in list) {
<li><% perl_uc($list[i]) %></li>
<!-- the "perl_uc" is the real perl uc() what is binded
with Javascript::V8::bind_function(perl_uc => sub { return uc(@_) }
-->
% }
</ul>
The above source should be "compiled" into JavaScript (Joose), and executed with Javascript::V8. (like in Mason - the source is compiled into perl/Moose object and executed with perl)...
As you can see, the for(var i in list)
is written in pure JS, and not in "mini-language"…