Add a simple FILTERS pragma example.
This includes examples of both section and interpolation filters.
This commit is contained in:
+88
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
class Filters
|
||||
{
|
||||
public $states = array(
|
||||
'al' => 'Alabama',
|
||||
'ak' => 'Alaska',
|
||||
'az' => 'Arizona',
|
||||
'ar' => 'Arkansas',
|
||||
'ca' => 'California',
|
||||
'co' => 'Colorado',
|
||||
'ct' => 'Connecticut',
|
||||
'de' => 'Delaware',
|
||||
'fl' => 'Florida',
|
||||
'ga' => 'Georgia',
|
||||
'hi' => 'Hawaii',
|
||||
'id' => 'Idaho',
|
||||
'il' => 'Illinois',
|
||||
'in' => 'Indiana',
|
||||
'ia' => 'Iowa',
|
||||
'ks' => 'Kansas',
|
||||
'ky' => 'Kentucky',
|
||||
'la' => 'Louisiana',
|
||||
'me' => 'Maine',
|
||||
'md' => 'Maryland',
|
||||
'ma' => 'Massachusetts',
|
||||
'mi' => 'Michigan',
|
||||
'mn' => 'Minnesota',
|
||||
'ms' => 'Mississippi',
|
||||
'mo' => 'Missouri',
|
||||
'mt' => 'Montana',
|
||||
'ne' => 'Nebraska',
|
||||
'nv' => 'Nevada',
|
||||
'nh' => 'New Hampshire',
|
||||
'nj' => 'New Jersey',
|
||||
'nm' => 'New Mexico',
|
||||
'ny' => 'New York',
|
||||
'nc' => 'North Carolina',
|
||||
'nd' => 'North Dakota',
|
||||
'oh' => 'Ohio',
|
||||
'ok' => 'Oklahoma',
|
||||
'or' => 'Oregon',
|
||||
'pa' => 'Pennsylvania',
|
||||
'ri' => 'Rhode Island',
|
||||
'sc' => 'South Carolina',
|
||||
'sd' => 'South Dakota',
|
||||
'tn' => 'Tennessee',
|
||||
'tx' => 'Texas',
|
||||
'ut' => 'Utah',
|
||||
'vt' => 'Vermont',
|
||||
'va' => 'Virginia',
|
||||
'wa' => 'Washington',
|
||||
'wv' => 'West Virginia',
|
||||
'wi' => 'Wisconsin',
|
||||
'wy' => 'Wyoming',
|
||||
);
|
||||
|
||||
// The next few functions are ugly, because they have to work in PHP 5.2...
|
||||
// for everyone who doesn't have to support 5.2, please, for the love, make
|
||||
// your ViewModel return closures rather than `array($this, '...')`
|
||||
//
|
||||
// :)
|
||||
|
||||
public function upcase()
|
||||
{
|
||||
return array($this, '_upcase');
|
||||
}
|
||||
|
||||
public function _upcase($val)
|
||||
{
|
||||
return strtoupper($val);
|
||||
}
|
||||
|
||||
public function eachPair()
|
||||
{
|
||||
return array($this, '_eachPair');
|
||||
}
|
||||
|
||||
public function _eachPair($val)
|
||||
{
|
||||
$ret = array();
|
||||
foreach ($val as $key => $value) {
|
||||
array_push($ret, compact('key', 'value'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{{%FILTERS}}
|
||||
{{# states | eachPair }}
|
||||
{{ key | upcase }}: {{ value }}
|
||||
{{/ states }}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
AL: Alabama
|
||||
AK: Alaska
|
||||
AZ: Arizona
|
||||
AR: Arkansas
|
||||
CA: California
|
||||
CO: Colorado
|
||||
CT: Connecticut
|
||||
DE: Delaware
|
||||
FL: Florida
|
||||
GA: Georgia
|
||||
HI: Hawaii
|
||||
ID: Idaho
|
||||
IL: Illinois
|
||||
IN: Indiana
|
||||
IA: Iowa
|
||||
KS: Kansas
|
||||
KY: Kentucky
|
||||
LA: Louisiana
|
||||
ME: Maine
|
||||
MD: Maryland
|
||||
MA: Massachusetts
|
||||
MI: Michigan
|
||||
MN: Minnesota
|
||||
MS: Mississippi
|
||||
MO: Missouri
|
||||
MT: Montana
|
||||
NE: Nebraska
|
||||
NV: Nevada
|
||||
NH: New Hampshire
|
||||
NJ: New Jersey
|
||||
NM: New Mexico
|
||||
NY: New York
|
||||
NC: North Carolina
|
||||
ND: North Dakota
|
||||
OH: Ohio
|
||||
OK: Oklahoma
|
||||
OR: Oregon
|
||||
PA: Pennsylvania
|
||||
RI: Rhode Island
|
||||
SC: South Carolina
|
||||
SD: South Dakota
|
||||
TN: Tennessee
|
||||
TX: Texas
|
||||
UT: Utah
|
||||
VT: Vermont
|
||||
VA: Virginia
|
||||
WA: Washington
|
||||
WV: West Virginia
|
||||
WI: Wisconsin
|
||||
WY: Wyoming
|
||||
Reference in New Issue
Block a user