partials

Rails rendering instance variable from application.html.erb

落花浮王杯 提交于 2019-12-22 05:34:22
问题 I am following the Agile Web Development with Rails 4 book and I'm a bit confused on a part about rendering. The simple version of the question is... within the application.html.erb file there it says render @cart This is confusing because I thought that there needed to be a controller associated with that view in order to know which partial and @cart variable to use. Is it simply by naming convention that this line looks for a partial like _cart.html.erb? And in that case does it not

What file path would I use with ng-include?

点点圈 提交于 2019-12-21 03:46:18
问题 My angular project's path is like this web server.py ##flask server program app static app.js controllers.js etc... templates index.html home.html index.html <!-- this didn't work --> <ng-include src="templates/home.html"><ng-include> <!-- nor did this --> <ng-include src="home.html"></ng-include> home.html <h1> home! </h1> Except I don't see the partial (home.html) in my output. Anyone see my mistake? 回答1: The src attribute of ng-include expects a string. Either you pass a scope variable, or

How to implement erb partials in a non rails app?

断了今生、忘了曾经 提交于 2019-12-20 12:38:56
问题 I want to do something like this: require 'erb' @var = 'test' template = ERB.new File.new("template.erb").read rendered = template.result(binding()) But how can I use partials in template.erb? 回答1: Perhaps brute-force it? header_partial = ERB.new(File.new("header_partial.erb").read).result(binding) footer_partial = ERB.new(File.new("footer_partial.erb").read).result(binding) template = ERB.new <<-EOF <%= header_partial %> Body content... <%= footer_partial %> EOF puts template.result(binding)

Why ng-scope is added to javascript inline of my partial view and makes alert not working?

橙三吉。 提交于 2019-12-17 09:48:17
问题 I'm using AngularJs with templating system. I want to add specific inline javascript script to each template adding alert box regards to the selected tab ( Home | List | Settings ) Html renders : but ng-scope is added and nothing alerts when you change of tabs. <script type="text/javascript" class="ng-scope">alert("home")</script> I make the example available here : http://bit.ly/HWcN1H or here plunkr example with alert("template1") present into template1.html but renders as <script type=

Is it possible to import a whole directory in sass using @import?

江枫思渺然 提交于 2019-12-17 02:59:34
问题 I am modularizing my stylesheets with SASS partials like so: @import partials/header @import partials/viewport @import partials/footer @import partials/forms @import partials/list_container @import partials/info_container @import partials/notifications @import partials/queues is there a way to include the whole partials directory(it's a directory full of SASS-partials) like @import compass or something? 回答1: If you are using Sass in a Rails project, the sass-rails gem, https://github.com

Rails: Nested views or partials or..?

我是研究僧i 提交于 2019-12-13 20:07:43
问题 I new to Ruby on Rails, and I am coming from Drupal/PHP background. I am trying to do something simple. A "Static" controller for some pages like about us, disclaimer etc. and a "Video" controller for videos. The whole application has same look. I am trying to figure out how I can avoid duplicating views. In drupal the theming goes like this: html.tpl.php (renders page.tpl.php) - page.tpl.php (renders multiple block.tpl.php) - block.tpl.php (renders more nested tpls or some html generated by

Passing variables through multiple partials (rails 4)

大憨熊 提交于 2019-12-13 05:47:56
问题 I am trying to pass instance variables through multiple partials and having trouble. undefined local variable or method "product" Application.html.erb" <%= render 'shared/footer', :product => @product %> _footer.html.erb <%= render 'shared/my_form', :product => product %> _my_form.html.erb <%= form_for( product ) %> UPDATE: I'm starting to think it might be that the instance variable @product is just not being set/passed for the redirect. Could the following be causing the issue? Opened

Why is Compass is giving me an import error when trying to import partials

时间秒杀一切 提交于 2019-12-12 14:17:14
问题 My compass project directory structure looks like this s3z@s3z:~/Desktop/compass_project$ tree . ├── basic.html ├── config.rb ├── css │ ├── ie.css │ ├── print.css │ └── screen.css ├── index.html ├── partials │ └── _normalize.scss └── sass ├── ie.scss ├── print.scss └── screen.scss My screen.scss file looks like this @import "compass"; @import "partials/normalize"; When I add @import "partials/normalize"; and save it, Compass spits the following error back at me >>> Compass is watching for

Render partials inside loop in Rails 5

心不动则不痛 提交于 2019-12-12 05:24:18
问题 Question: How do I make a partial (that has to be generic) loop through different variables? I have a tabbed page where I want to use a partial to avoid duplicating my HTML. The tabs are "Videos" and "Articles". It's the exact same HTML but I want to iterate through @videos for videos and @articles for articles. The idea was to make the product partial completely generic and then somehow pass in @videos or @articles that I want to iterate through. Partial: _product.html.slim .col-md-5

Getting array of option closing tags after partial containing options [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-12 03:55:20
问题 This question already has answers here : What is the difference between <%, <%=, <%# and -%> in ERB in Rails? (7 answers) Closed 4 months ago . I have dynamic select boxes in my view ../diys/_form.htmlerb ... <%= f.fields_for :attached_vehicles do |av| %> <p>Select make</p> <%= av.select :make, options_for_select(@makes.collect { |make|[make.make_name, make.id] }, 0), {}, { id: 'makes_select' } %><br> <p>Select model</p> <%= av.select :model, (render "make_models/make_model"), {}, { id: