Skip to content

Commit df47d32

Browse files
committed
Adde route and site_url parser plugins.
1 parent 20d5d02 commit df47d32

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

system/Config/View.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class View extends BaseConfig
6868
'safe_mailto' => '\CodeIgniter\View\Plugins::safeMailto',
6969
'lang' => '\CodeIgniter\View\Plugins::lang',
7070
'validation_errors' => '\CodeIgniter\View\Plugins::validationErrors',
71+
'route' => '\CodeIgniter\View\Plugins::route',
72+
'siteURL' => '\CodeIgniter\View\Plugins::siteURL',
7173
];
7274

7375
public function __construct()

system/View/Plugins.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,27 @@ public static function ValidationErrors(array $params = [])
125125
return $validator->showError($params['field']);
126126
}
127127

128+
//--------------------------------------------------------------------
129+
130+
/**
131+
* @param array $params
132+
*
133+
* @return string|
134+
*/
135+
public static function route(array $params = [])
136+
{
137+
return route_to(...$params);
138+
}
139+
140+
//--------------------------------------------------------------------
141+
142+
/**
143+
* @param array $params
144+
*
145+
* @return string
146+
*/
147+
public static function siteURL(array $params = [])
148+
{
149+
return site_url(...$params);
150+
}
128151
}

user_guide_src/source/general/view_parser.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,12 @@ Plugin Arguments Description
481481
==================== ========================== ================================================================================== ================================================================
482482
current_url Alias for the current_url helper function. {+ current_url +}
483483
previous_url Alias for the previous_url helper function. {+ previous_url +}
484+
site_url Alias for the site_url helper function. {+ site_url "login" +}
484485
mailto email, title, attributes Alias for the mailto helper function. {+ mailto email=foo@example.com title="Stranger Things" +}
485486
safe_mailto email, title, attributes Alias for the safe_mailto helper function. {+ safe_mailto email=foo@example.com title="Stranger Things" +}
486487
lang language string Alias for the lang helper function. {+ lang number.terabyteAbbr +}
487488
validation_errors fieldname(optional) Returns either error string for the field (if specified) or all validation errors. {+ validation_errors +} , {+ validation_errors field="email" +}
489+
route route name Alias for the route_to helper function. {+ route "login" +}
488490
==================== ========================== ================================================================================== ================================================================
489491

490492
Registering a Plugin

0 commit comments

Comments
 (0)