Support the ongoing development of Laravel.io →
posted 8 years ago
Blade
Last updated 2 years ago.
0

Are you taking the result of the view and then using that as a template?

I ask because if I understand,

$article->html = '<b>test @myCustomDirective('test')</b>' 

The directive is not executed.

What are you trying to do?

0

Yes that's it. The directive is not executed, {!! $article->html !!} print me : test @myCustomDirective('test')

0

You put the directive in the template,

{{ @myCustomDirective ('test') }}

This will run the directive, passing the variable of test to it.

0

I would like to create directive such as "html" tag, that's mean :

$article->html contains my html data from my wyswyg which implements some new html tag, like @ipcodes('specific ip category name') displaying the ipcode of the parameter.

0

Ok,

Then you will need to either save the $article->html to a temp file then use that as a template for blade or you can use my StringBladeCompiler class which lets you use a string as a template.

If your using Laravel 5.1+, it would be something like this

// store the original $article->html in the db, so that it can be edited with the blade directives
// otherwise you will lose the @ipcodes from the text

// update the value to display
$html = View($article->html, [] );

The $html var should contain the processed result of the blade directives. You might need to setup the directives slightly different, but it shouldn't be much of a problem.

It is a little more code if your still using Laravel 4.2. and 5.0

Take a look at the GitHub for the project, https://github.com/TerrePorter/StringBladeCompiler and find the right branch for your version of Laravel.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Blue blue Joined 6 Feb 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.