samedi 21 mai 2016

Laravel blade @include into a Javascript variable?

In a Laravel 5 blade template I have a <script> section.

In this section I need to set a variable to a string that is coming from another blade template.

I tried something like :

<script>
  var a = "@include 'sometext.blade.php' ";
</script>

but this obviously doesn't work.

Also, the included blade can contain both single and double quotes, so these need to be escaped somehow, or the Javascript will not be valid.

Any ideas?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire