-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-app
44 lines (38 loc) · 1002 Bytes
/
test-app
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
#! /usr/bin/env perl
use Mojolicious::Lite;
plugin 'InlineJSON';
get '/' => sub {
my $c = shift;
$c->stash( the_data => { your => 'fez', is => 'smelly>' });
$c->render;
}, 'test';
app->start;
__DATA__
@@test.html.ep
<head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<h1> Using js_data </h1>
<div id="js-data" v-for="(val, key) in jsData" :key="key">
The key is <span :class="key"> "{{ key }}" </span>
and the value is <span :class="val"> "{{ val }}" </val>
</div>
<hr>
<h1> Using js_data_via_json </h1>
<div id="js-data-via-json" v-for="(val, key) in jsonData" :key="key">
The key is <span class="key"> "{{ key }}" </span>
and the value is <span class="val"> "{{ val }}" </val>
</div>
</div>
</body>
<script>
var app = new Vue({
el: '#app',
data: {
jsData: <%== js_data($the_data) %>,
jsonData: <%== js_data_via_json($the_data) %>
}
})
</script>