コード例 #1
0
ファイル: ex2.php プロジェクト: magnusjt/regtemplate_php
<?php

include __DIR__ . '/../vendor/autoload.php';
$template = new \RegTemplate\RegTemplate();
$template->parse_template('
Card {{ card_name }}: {{ cpu|float }}%
');
$matches = $template->match_all('
--- CPU Table ---
Card 1-1: 45.6%
Card 1-2: 43.6%
Card 2-1: 13.56%
Card 2-2: 99.0%
');
var_dump($matches);
コード例 #2
0
ファイル: ex3.php プロジェクト: magnusjt/regtemplate_php
<?php

include __DIR__ . '/../vendor/autoload.php';
$template = new \RegTemplate\RegTemplate();
$template->parse_template('
There {{ is_are|reg="(?:is|are)" }} {{ number|digits }} instance{{ plural|reg="s?" }} of this.
');
$matches = $template->match('
There is 1 instance of this.
');
var_dump($matches);
$matches = $template->match('
There are 10 instances of this.
');
var_dump($matches);
$matches = $template->match_all('
There is 1 instance of this.
There are 20 instances of this.
There are 30 instances of this.
');
var_dump($matches);
コード例 #3
0
ファイル: ex1.php プロジェクト: magnusjt/regtemplate_php
<?php

include __DIR__ . '/../vendor/autoload.php';
$template = new \RegTemplate\RegTemplate();
$template->parse_template('
Displaying numbers from index {{ index_name|word }}
Number of interesting events: {{ num_events|digits }}
Number of pages: {{ num_pages|digits }} blarg
');
$matches = $template->match('
Displaying numbers from index SuperIndex
Number of interesting events: 45678
Number of pages: 9876 blarg
');
var_dump($matches);