Skip to content

Commit ac076e6

Browse files
committed
Working on formatting.
1 parent 20b69aa commit ac076e6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

templates.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,17 @@ By default, sections are appended to any previous content that exists in the sec
164164
<a name="extending-blade"></a>
165165
## Extending Blade
166166

167-
Blade allows you to define your own custom control structures. When a Blade file is compiled, each extension is ran over the view contents, allowing you to do anything from regular `str_replace` to more complex regex.
167+
Blade even allows you to define your own custom control structures. When a Blade file is compiled, each custom extension is called with the view contents, allowing you to do anything from simple `str_replace` manipulations to more complex regular expressions.
168168

169-
The Blade compiler comes with the methods `createMatcher` and `createPlainMatcher` which generates the regex you need to generate your own custom control structures.
169+
The Blade compiler comes with the helper methods `createMatcher` and `createPlainMatcher`, which generate the expression you need to build your own custom directives.
170170

171-
`createPlainMatcher` is used for control structures with no arguments (like `@endif`, `@stop`) while `createMatcher` is used for controls with arguments.
171+
The `createPlainMatcher` method is used for directives with no arguments like `@endif` and `@stop`, while `createMatcher` is used for directives with arguments.
172172

173-
This example creates an `@datetime($var)` control structure which just calls `->format()` on `$var`, assuming it is a DateTime or Carbon object.
173+
The following example creates a `@datetime($var)` directive which simply calls `->format()` on `$var`:
174174

175-
Blade::extend(function($view, $compiler) {
175+
Blade::extend(function($view, $compiler)
176+
{
176177
$pattern = $compiler->createMatcher('datetime');
178+
177179
return preg_replace($pattern, '$1<?php echo $2->format('m/d/Y H:i'); ?>', $view);
178-
});
180+
});

0 commit comments

Comments
 (0)