Permalink
4 comments
on commit
sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
40 additions
and 0 deletions.
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Illuminate\View\Compilers\Concerns; | ||
|
||
trait CompilesFormHelpers | ||
{ | ||
/** | ||
* Compile the CSRF statements into valid PHP. | ||
* | ||
* @return string | ||
*/ | ||
protected function compileCsrf() | ||
{ | ||
return '<?php echo csrf_field(); ?>'; | ||
} | ||
|
||
/* | ||
* Compile the method statements into valid PHP. | ||
* | ||
* @param string $method | ||
* @return string | ||
*/ | ||
protected function compileMethod($method) | ||
{ | ||
return "<?php echo method_field{$method}; ?>"; | ||
} | ||
} |
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\View\Blade; | ||
|
||
class BladeFormHelpersTest extends AbstractBladeTestCase | ||
{ | ||
public function testEchosAreCompiled() | ||
{ | ||
$this->assertEquals('<?php echo csrf_field(); ?>', $this->compiler->compileString('@csrf')); | ||
$this->assertEquals('<?php echo method_field(\'patch\'); ?>', $this->compiler->compileString("@method('patch')")); | ||
} | ||
} |
This comment has been minimized.
@taylorotwell Why master and not 5.5?
This comment has been minimized.
cool stuff😎
This comment has been minimized.
Ugh, my OCD! Why is the first method written with single quotes and the second with double quotes!😄
This comment has been minimized.
@JPortegijs The second method uses a variable.