Thread Daten aus einer JSON-Response referenzieren (5 answers)
Opened by NickHatBoecker at 2019-06-17 10:22

rosti
 2019-06-17 18:31
#190122 #190122
User since
2011-03-19
3492 Artikel
BenutzerIn
[Homepage]
user image
Beispiel mit CPAN:Template::Mustache:

Code (perl): (dl )
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
use strict;
use warnings;
use Template::Mustache;

my $countries = [
    {id => 190, label => "Afghanistan"},
    {id => 2,   label => "Ägypten"}
];

my $template = q(
    <select name="countries">
    {{#countries}}
        <option id="{{id}}" value="{{& label}}">{{& label}}</option>
    {{/countries}} 
    </select>
);

print Template::Mustache->render($template, {countries => $countries});

Ausgabe:

    <select name="countries">
        <option id="190" value="Afghanistan">Afghanistan</option>
        <option id="2" value="Ägypten">Ägypten</option>
    </select>

Last edited: 2019-06-17 18:33:30 +0200 (CEST)

View full thread Daten aus einer JSON-Response referenzieren