/
Javascript.pm
56 lines (47 loc) · 1.27 KB
/
Javascript.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use strictures 1;
package Mojito::Template::Role::Javascript;
use Moo::Role;
use MooX::Types::MooseLike::Base 0.03 qw(:all);
use Data::Dumper::Concise;
=head1 Name
Mojito::Template::Role::Javascript - a class for Javascript resources
=cut
with('Mojito::Role::Config');
has javascripts => (
is => 'ro',
isa => ArrayRef,
lazy => 1,
builder => '_build_javascripts',
);
sub _build_javascripts {
[
'jquery/jquery.min.js',
'javascript/render_page.js',
'javascript/style.js',
'javascript/publish.js',
'syntax_highlight/prettify.js',
'jquery/jquery-ui.custom.min.js',
'SHJS/sh_main.min.js',
'SHJS/sh_perl.min.js',
'SHJS/sh_javascript.min.js',
'SHJS/sh_html.min.js',
'SHJS/sh_css.min.js',
'SHJS/sh_sql.min.js',
'SHJS/sh_sh.min.js',
'SHJS/sh_diff.min.js',
'SHJS/sh_haskell.min.js',
];
}
has javascript_html => (
is => 'ro',
isa => ArrayRef,
lazy => 1,
builder => '_build_javascript_html',
);
sub _build_javascript_html {
my $self = shift;
my $static_url = $self->config->{static_url};
my @javascripts = map { "<script src=${static_url}$_></script>" } @{$self->javascripts};
[@javascripts];
}
1