Skip to content

Commit

Permalink
Added disabled directive (#40900)
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Belz <aaron.belz@flowbird.group>
  • Loading branch information
belzaaron and belzaaron committed Feb 10, 2022
1 parent 6f09b4e commit 9f59411
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Illuminate/View/Compilers/Concerns/CompilesConditionals.php
Expand Up @@ -326,4 +326,15 @@ protected function compileChecked($condition)
{
return "<?php if{$condition}: echo 'checked'; endif; ?>";
}

/**
* Compile a disabled block into valid PHP.
*
* @param string $condition
* @return string
*/
protected function compileDisabled($condition)
{
return "<?php if{$condition}: echo 'disabled'; endif; ?>";
}
}
8 changes: 8 additions & 0 deletions tests/View/Blade/BladeCheckedStatementsTest.php
Expand Up @@ -19,4 +19,12 @@ public function testCheckedStatementsAreCompiled()

$this->assertEquals($expected, $this->compiler->compileString($string));
}

public function testDisabledStatementsAreCompiled()
{
$string = '<button @disabled(name(foo(bar)))>Foo</button>';
$expected = "<button <?php if(name(foo(bar))): echo 'disabled'; endif; ?>>Foo</button>";

$this->assertEquals($expected, $this->compiler->compileString($string));
}
}

0 comments on commit 9f59411

Please sign in to comment.