Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using layout in controller #201

Open
tomkadwill opened this issue Jun 11, 2014 · 1 comment
Open

Using layout in controller #201

tomkadwill opened this issue Jun 11, 2014 · 1 comment
Labels

Comments

@tomkadwill
Copy link

I want to use a layout as a base for all of my views so my controller looks like:

defmodule ElixirWeberTest.Main do

  use Weber.Controller
  layout "application.html"

  def index([], _conn) do
    {:render, [], []}
  end

  def show([], _conn) do
    {:render, [foo: 'foo'], []}
  end
end

When I load the view for show get a page in the browser that looks like:

hi <%= 'Tom' %>
<%= @foo %>

If I remove use Weber.Controller and layout "application.html" then the view loads correctly displaying values in place of the tags.

Not sure if this is a bug or if I am doing something wrong. If this is confirmed as a bug then I am happy to work on a fix :)

@rcdilorenzo
Copy link
Contributor

Yes. I believe this is an issue. I think I've actually seen it before. I do know that the workaround is to replace the content_for_layout with an evaluation of the string passed in:

<%= EEx.eval_string @content_for_layout, assigns: assigns %>

Therefore, the layout manager probably just needs to make sure that it evaluates the content passed in. If you can make a pull-request for this, that would be fantastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants