You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,15 @@ $app->run();
58
58
59
59
## Custom template functions
60
60
61
-
This component exposes a custom `path_for()` function to your Twig templates. You can use this function to generate complete URLs to any Slim application named route. This is an example Twig template:
61
+
`TwigExtension` provides these functions to your Twig templates:
62
+
63
+
*`path_for()` - returns the URL for a given route.
64
+
*`base_url()` - returns the `Uri` object's base URL.
65
+
*`is_current_path()` - returns true is the provided route name and parameters are valid for the current path.
66
+
*`current_path()` - renders the current path, with or without the query string.
67
+
68
+
69
+
You can use `path_for` to generate complete URLs to any Slim application named route and use `is_current_path` to determine if you need to mark a link as active as shown in this example Twig template:
62
70
63
71
{% extends "layout.html" %}
64
72
@@ -70,6 +78,7 @@ This component exposes a custom `path_for()` function to your Twig templates. Yo
0 commit comments