Skip to content
Discussion options

You must be logged in to vote

It should be something like this

Blade::directive('required', function ($condition) {
     return "<?php if({$condition}): echo 'required'; endif; ?>";
});
/* more generic 
 @echoif('required', $condition) 
 @echoif('readonly', $condition)
 @echoif('data-value="true"', $condition) */
Blade::directive('echoif', function($arguments){ 
    $args = explode(',', $arguments), 2); 
    return "<?php if({$args[1]}): e({$args[0]}); endif; ?>";
});

Just put that on your ViewServiceProvider

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@erikn69
Comment options

@GuidoBelluomo
Comment options

Answer selected by GuidoBelluomo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants