gobuffalo / plush

The powerful template system that Go needs
MIT License
901 stars 56 forks source link

contentFor in partials #100

Closed random-char closed 3 years ago

random-char commented 5 years ago

Receiving error when using contentFor in partials. Need to move them up (see example for better understanding): The way it works

//entity/create.html
<h1>Create</h1>
<%= contentFor("extraJS") {%>
    var someVar = 1;
<%} %>
<%= partial("entity/form.html") %>

The way it doesn't (contentFor block is not present in create.html anymore)

//entity/_form.html
<%= form...%>
<%= contentFor("extraJS") {%>
    var someVar = 1;
<%} %>

Is it expected or am I doing something wrong?

random-char commented 5 years ago

After spending some time, I've stumbled upon an issue that the context in the partial and in outer template are different. Is there a way to use same outer context in the partial?

paganotoni commented 5 years ago

I've also faced this one. a PR is welcome @random-char!

paganotoni commented 3 years ago

@random-char this one may be fixed with #140 want to give it a shot?