The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::NodeTransformator - interface to node transformator

VERSION

Version 0.100

SYNOPSIS

        use Net::NodeTransformator;
        
        my $nnt = Net::NodeTransformator->new;
        
        my $jade_in = <<'EOT';
        span
          | Hi #{name}!
        EOT
        
        my $jade_vars = {
                name => 'Peter'
        };
        
        my $jade_out = $nnt->jade($jade_in, $jade_vars);

DESCRIPTION

This module is an interface to the transformator package of nodejs. See https://www.npmjs.org/package/transformator for more information about the server.

When it's difficult for perl to interact with various nodejs packages, the transformator protocol allows everyone to interact with an nodejs service. transformator supports a vast range of libraries like jade-lang, sass-lang or coffeescript.

The other way is to invoke each command-line tool as a child process, but this may be very inefficient if such tool need to be called frequently.

METHODS

new($hostport)

Set the hostname/port or unix domain socket for connecting to transformator.

        Net::NodeTransformator->new('12345');
        Net::NodeTransformator->new('localhost:12345');
        Net::NodeTransformator->new('path/to/unix/domain/socket');      

transform_cv(%options)

Connects to transformator and waits for the result asynchronously by using a condition variable.

%options requires for keyworks:

engine The engine to be used
input The input string
data (optional) Additional data to be send with. Currently only meaningful for jade engine.
on_error A callback subroutine called in case of any error

This method returns a condition variable (AnyEvent->condvar)

        my $cv = $nnt->transform_cv(...);

The result will be pushed to the condvar, so $cv-recv> will return the result.

transform($engine, $input, $data)

This is the synchronous variant of transform_cv. It croaks on error and can be catched by Try::Tiny for example.

SHORTCUT METHODS

This list is incomplete. I will add more methods on request. All methods are hopefully self-describing.

jade($input, $data)

coffeescript($input)

minify_html($input)

minify_css($input)

minify_js($input)

AUTHOR

David Zurborg, <zurborg@cpan.org>

BUGS

Please report any bugs or feature requests at https://github.com/zurborg/libnet-nodetransformator-perl/issues. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Net::NodeTransformator

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2014 David Zurborg, all rights reserved.

This program is released under the ISC license.