1
votes

I'm trying to find the Phoenix Equivalent of rails' params[:controller], so that I can serve stylesheets and javascript files based on the controller rendering the view.

In Rails, you could simply do this:

<%= stylesheet_link_tag    'application', params[:controller] %> 
<%= javascript_include_tag 'application', params[:controller] %>

Source: Rails Asset Pipeline - Controller Specific Assets


I'm trying to do the same thing in Phoenix. I'm separating my Sass files according to their controllers. Maybe something like this?

<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
<link rel="stylesheet" href="<%= static_path(@conn, "/css/#{@controller}.css") %>"> 
1

1 Answers