0

I want user to be able to edit their own email contents on the Admin backend panel and user can use some directives such as:

  • Date {{date}}
  • Time {{dime}}
  • Customer Name (get via db) {{customer.name}}
  • Customer Number (get via db) {{customer.phone}}
  • if statement @if @else @endif

So, for example user could do something like this in the <textarea>:

 @if(customer.name) Dear {{customer.name}} @endif

How do I create some custom directives in Laravel, any library I can use to ease development? Of course user is not allowed to use PHP code.

I know there is Laravel Blade but I am not sure that is safe to use for public users to edit contents and only allow customer directives only.

I'll-Be-Back
  • 10,530
  • 37
  • 110
  • 213

1 Answers1

0

You can use different syntax than Blade, then translate it to Blade

@if(customer.name) Dear {{customer.name}} @endif

would become

#if[customer.name] Dear [[customer.name]] #endif

than create a function that replaces # with @ and so on.

Check this : PHP Looping Template Engine - From Scratch

Community
  • 1
  • 1
flakerimi
  • 2,580
  • 3
  • 29
  • 49