Closed austinkregel closed 9 years ago
For a quick fix until I am told other wise, I have implemented this quick fix inside the Bkwld\LaravelHaml\HamlBladeCompiler
class
public function compile($path) {
if (is_null($this->cachePath)) return;
// First compile the Haml
$contents = $this->mthaml->compileString($this->files->get($path), $path);
// Then the Blade syntax
$contents = $this->compileString($contents);
// Save
$this->files->put($this->getCompiledPath($path), html_entity_decode($contents,ENT_QUOTES));
}
I added the html_entity_decode function to the very last line
You could do this:
%form.form-horizontal{:action => url('/auth/login'), :method => "POST", :role => "form"}
Or, fwiw, the syntax I use is:
%form.form-horizontal(action=url('/auth/login') method='POST' role='form')
Lastly, you could turn off the auto-escaping altogether as described in the docs:
// Publish the config file and then configure like:
<?php return array(
'mthaml' => array(
'environment' => 'php',
'options' => array('enable_escaper' => false),
'filters' => array(),
),
);
I tested these out and they're working for me.
I do have the auto-escaping disabled, and this problem still wasn't fixed, any who thank you ^.^
Huh. Some other qs:
%form.form-horizontal{:action => url('/auth/login')}
Laravel 5, and no, I actually got more errors when I switched my view over to with of the solutions you gave.
The only thing that has worked is html_entity_decode in the compile function.
Also, I don't know if it is this package or if it's blade itself, but I have an infinite loop when I @yield('content')
@trupedia can you see if you can recreate these issues since you're the blade user?
I refreshed my project page right before I posted that comment just to make sure it was still happening, then I posted the comment, right after that I went back to my project, removed the @
in front of yield and refreshed the page. There was no infinite loop. I put in the @
again and that issue was fixed. As for the previous issue, I'm still having that one...
@austinkregel which file extension do you use exactly?
And could you paste the content of your template file please, that I can recreate it in my install of Laravel 5?
Thanks :)
I use the haml.blade.php
extension.
The app.haml.blade.php
file
!!!
%html{:lang => "en"}
%head
%meta{:charset => "utf-8"}
%meta{:content => "IE=edge", "http-equiv" => "X-UA-Compatible"}
%meta{:content => "width=device-width, initial-scale=1", :name => "viewport"}
%title Laravel
%link{:href => "{{ asset('/css/app.css') }}", :rel => "stylesheet"}
/ Fonts
%link{:href => "//fonts.googleapis.com/css?family=Roboto:400,300", :rel => "stylesheet", :type => "text/css"}
/ HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries
/ WARNING: Respond.js doesn't work if you view the page via file://
/[if lt IE 9]
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
%link{:href => "//fonts.googleapis.com/css?family=Lato:100", :rel => "stylesheet", :type => "text/css"}
:css
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
color: gray;
display: table;
font-weight: 100;
font-family: 'Lato';
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 72px;
margin-bottom: 40px;
}
%body
%nav.navbar.navbar-default
.container-fluid
.navbar-header
%button.navbar-toggle.collapsed{"data-target" => "#bs-example-navbar-collapse-1", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle Navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
%a.navbar-brand{:href => "#"} Laravel
#bs-example-navbar-collapse-1.collapse.navbar-collapse
%ul.nav.navbar-nav
%li
%a{:href => "{{ url('/') }}"} Home
%ul.nav.navbar-nav.navbar-right
@if (Auth::guest())
%li
%a{:href => "{{ url('/backend/auth/login') }}"} Login
%li
%a{:href => "{{ url('/backend/auth/register') }}"} Register
@else
%li.dropdown
%a.dropdown-toggle{"aria-expanded" => "false", "data-toggle" => "dropdown", :href => "#", :role => "button"}
{!! Auth::user()->name !!}
%span.caret
%ul.dropdown-menu{:role => "menu"}
%li
%a{:href => "{{ url('/backend/auth/logout') }}"} Logout
@endif
@yield('content')
/ Scripts
%script{:src => "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"}
%script{:src => "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"}
And the actual haml/blade offender the auth/login.haml.blade.php
file
@extends('app')
@section('content')
.container-fluid
.row
.col-md-8.col-md-offset-2
.panel.panel-default
.panel-heading Login
.panel-body
@if (count($errors) > 0)
.alert.alert-danger
%strong Whoops!
There were some problems with your input.
%br
%br
%ul
@foreach ($errors->all() as $error)
%li {{ $error }}
@endforeach
@endif
%form.form-horizontal{:action => "{{ url('/backend/auth/login') }}", :method => "POST", :role => "form"}
%input{:name => "_token", :type => "hidden", :value => "{{ csrf_token() }}"}
.form-group
%label.col-md-4.control-label E-Mail Address
.col-md-6
%input.form-control{:name => "email", :type => "email", :value => "{{ old('email') }}"}
.form-group
%label.col-md-4.control-label Password
.col-md-6
%input.form-control{:name => "password", :type => "password"}
.form-group
.col-md-6.col-md-offset-4
.checkbox
%label
%input{:name => "remember", :type => "checkbox"}
Remember Me
.form-group
.col-md-6.col-md-offset-4
%button.btn.btn-primary{:type => "submit"} Login
%a.btn.btn-link{:href => "{{ url('/password/email') }}"} Forgot Your Password?
@endsection
This is for the Auth\AuthController@getLogin
method, note: I have not modified the method in my controller at all.
Please note that this has nothing to do with the original problem I was having, and appears to have been fixed (I have no clue what I did)
@austinkregel I could'nt reproduce the issue with the @yield()
loop in my installation.
But as @weotch said, you have to change the syntax like this, to get HAML and Blade work smoothly together:
!!!
%html{:lang => "en"}
%head
%meta{:charset => "utf-8"}
%meta{:content => "IE=edge", "http-equiv" => "X-UA-Compatible"}
%meta{:content => "width=device-width, initial-scale=1", :name => "viewport"}
%title Laravel
%link{:href => asset('/css/app.css'), :rel => "stylesheet"}
/ Fonts
%link{:href => "//fonts.googleapis.com/css?family=Roboto:400,300", :rel => "stylesheet", :type => "text/css"}
%body
%nav.navbar.navbar-default
.container-fluid
.navbar-header
%button.navbar-toggle.collapsed{"data-target" => "#bs-example-navbar-collapse-1", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle Navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
%a.navbar-brand{:href => "#"} Laravel
#bs-example-navbar-collapse-1.collapse.navbar-collapse
%ul.nav.navbar-nav
%li
%a{:href => url('/')} Home
%ul.nav.navbar-nav.navbar-right
@if (Auth::guest())
%li
%a{:href => url('/auth/login')} Login
%li
%a{:href => url('/auth/register')} Register
@else
%li.dropdown
%a.dropdown-toggle{"aria-expanded" => "false", "data-toggle" => "dropdown", :href => "#", :role => "button"}
{{ Auth::user()->name }}
%span.caret
%ul.dropdown-menu{:role => "menu"}
%li
%a{:href => url('/auth/logout')} Logout
@endif
@yield('content')
/ Scripts
%script{:src => "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"}
%script{:src => "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"}
Surprisingly on my homestead machine, I couldn't recreate the @yield()
error, but on a production machine it occurred. Implemented a fix on the master branch
I checked it on my production machine, error didn't appear again.
@austinkregel could you require "dev-master" in your project and check if the yield issue is still present?
@weotch Should we change the current tag or create a minor version for the commit, if the solution is confirmed?
Intererresting.... yeah, we'll make a minor release when @austinkregel confirms.
Thanks @trupedia !
I'm starting my check right now.
Upon updating, everything looks like it is working just fine. Thank you for confirming this and letting me know I'm not nuts. The haml.blade.php pages work without an issue.
Great :)
Ok, this is tagged now as 2.3.1
For some reason this package is not compiling the blade functions with the quotes. Below is what it's compiling to.
compared to what I have typed.