Skip to content

Conversation

@carcinocron
Copy link

This is wrong:

The following example creates a `@datetime($var)` directive which simply calls `->format()` on `$var`:

    Blade::extend(function($view, $compiler)
    {
        $pattern = $compiler->createMatcher('datetime');

        return preg_replace($pattern, '$1<?php echo $2->format('m/d/Y H:i'); ?>', $view);
    });

This has 2 errors in it:

  1. 'm/d/Y H:i' isn't properly escaped.
  2. @datetime($var) becomes ($var)->format() and crashes instead of $var->format()

Previous discussion: laravel/framework#4770 and #835

@carcinocron carcinocron changed the title Update templates.md Section "Extending Blade" is wrong Jun 20, 2014
taylorotwell added a commit that referenced this pull request Jun 27, 2014
Section "Extending Blade" is wrong
@taylorotwell taylorotwell merged commit 161b215 into laravel:4.1 Jun 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants