Error printing Styles and scripts in Blade templates?

Asked

Viewed 155 times

2

I have a CMS that is using Elementor to generate pages dynamically, this saves my html css and script in the database. I had a problem with the tag issue <style> and <script> because Lade was not accepting this in the templates so I created Stacks in app.blade.php for them (I don’t think it’s the best option, but for now it will stay that way). But scripts can come with html when printing and the templates do not build again, that is, it works if the created page is simple. Why doesn’t Blade 'compile' templates when I use scripts and Styles right in them? And do you have anything to answer that question?

@extends('front.layouts.page') 
@section('content')
<div class="cursosPage ui-container-bottom">
  <the-pages-scroll></the-pages-scroll>
  <div class="container">
    <div class="row">
      {!! $dynamicPage['html'] !!}
    </div>
  </div>
</div>
@push('styles')
  <style>
    {{ $dynamicPage['css'] }}
  </style>
@endpush 
@push('scripts')
  <script>
      {{ $dynamicPage['javascript'] }}
  </script>
@endpush @endsection

@EDIT: Console error (displays all code called on @extends)

Erro quando alguma tag <script> ou <style> existe

  • The syntax {!! valor !!} does not escape anything so html is supposed to be interpreted normally. What error it gives ?

  • I edited the question, ta ai. Remembering that only this error if you have a tag <script> or <style> within html

  • @Taylorroos You could ask your question what you actually have inside the $dynamicPage['html'], $dynamicPage['css'] and $dynamicPage['javascript' ]? This could be an example. Because I did a test now containing css, html and js in that order within a variable or three separate and it worked.. use {!! !! } in the css variable and javascript to render html instead of {{ }}, this may be your problem.

2 answers

-1

This mistake is asking you to declare <div class="app"></div>

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.