-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add csrf and method blade directives
- Loading branch information
1 parent
6563ba6
commit 5f19844
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Illuminate/View/Compilers/Concerns/CompilesFormHelpers.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}; ?>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')")); | ||
} | ||
} |
5f19844
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taylorotwell Why master and not 5.5?
5f19844
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool stuff π
5f19844
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, my OCD! Why is the first method written with single quotes and the second with double quotes! π
5f19844
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JPortegijs The second method uses a variable.