partials

Asp.Net MVC 3 - @Html.Action won't render/return any HTML

本小妞迷上赌 提交于 2019-12-05 05:50:30
I've been moving a fairly new project from ViewPages to Razor today, and all seems to be going well. Except I'm trying to use Html.Action to render a user control and it won't render anything. So I have a Shared/_Layout.cshtml file which is referenced in Home/Index.cshtml Index.cshtml has the following: <article> @Html.Action("LatestBlogsMainPanelWidget", "Blogs") ... </article> I've put traps in the BlogsController, so I know that's being requested. I also know that a model is being returned, that the LatestBlogsMainPanelWidget is being found by the view engine, and even some dummy Razor

How to pass multiple locals to a nested partial

倖福魔咒の 提交于 2019-12-04 12:49:46
This should be extremely straightforward and well documented, and I've done it several times, although there's something that's still killing me. I have a structure of partials calling nested partials. At some point one render call needs to pass an extra variable to the partial, although the rendering of the partial fails with a: undefined local variable or method `<variable name>' for #<#<Class:....> Here's my code for calling the render : = f.simple_fields_for :orders do |c| = render partial: "fields", locals: {f: c, step: f.object.step} though this doesn't work either: = f.simple_fields_for

Nodejs EJS partials with scripts in the head

元气小坏坏 提交于 2019-12-04 07:25:57
I'm working with EJS to render and server HTML pages from a Nodejs server. Some of the partials I include have scripts and stylesheets referenced in the head, but this causes the client to make multiple requests for the same file (for example if the parent view also includes that file) For example: <!-- file: parent.ejs --> <html> <head> <link rel="stylesheet" href="public/mystylesheet.css"> <script src="public/myscript.js"> </head> <body> <%- partial("partial.ejs") %> </body> </html> And in the partial: <!-- file: partial.ejs --> <html> <head> <link rel="stylesheet" href="public/mystylesheet

How to use the partial in zendframework2

笑着哭i 提交于 2019-12-04 07:22:48
In ZF1 we use partial in layout.phtml file something like that $this->partial('header.phtml', array('vr' => 'zf2')); How we can do the same in ZF2? this can be achieved by echo $this->partial('layout/header', array('vr' => 'zf2')); you can access the variable in view using echo $this->vr; don't forget to add following line in your view_manager of module.config.php file. 'layout/header' => __DIR__ . '/../view/layout/header.phtml', after adding it looks like this return array( 'view_manager' => array( 'template_path_stack' => array( 'user' => __DIR__ . '/../view' , ), 'display_not_found_reason'

Passing instance variable to js.erb file (Rails 3 / jQuery)

こ雲淡風輕ζ 提交于 2019-12-04 06:40:31
I have an "index.html.erb" file with the following: <%= render @users %> This renders "_user.html.erb" and outputs a button for performing a certain action on each user: <%= link_to "action", action_path(user), :id => "#{user.id}_action", :remote => true) %> I've set up my User controller to respond to the AJAX request by looking at "action.js.erb". In order to perform javascript methods on particular users within the partial, and I'd like to know how instance variables from my partial (such as user.id) can be passed into or accessed within the js.erb file, for instance: $("#{@user.id}_action"

Where to put partials shared by the whole application in Rails?

左心房为你撑大大i 提交于 2019-12-03 18:55:22
问题 Where would I go about placing partial files shared by more than one model? I have a page called crop.html.erb that is used for one model - Photo . Now I would like to use it for another model called User as well. I could copy and paste the code but that's not very DRY, so I figured I would move it into a partial. Since it's shared between two models - where would I place that partial ? Thanks! 回答1: The Rails convention is to put shared partials in /app/views/shared . 回答2: Update Layout

Using variables for a partial template

余生颓废 提交于 2019-12-03 11:23:55
问题 I'm definitely missing something about the way Handlebars works. I need to call different partials depending on the value of a variable. Currently the only way I've found to do it is this: <template name="base"> {{#if a}}{{> a}}{{/if}} {{#if b}}{{> b}}{{/if}} {{#if c}}{{> c}}{{/if}} </template> And in the corresponding JS: Template.base.a = function () { return (mode === "a"); } Template.base.b = function () { return (mode === "b"); } Template.base.c = function () { return (mode === "c"); } .

Sass @import using leading underscore

这一生的挚爱 提交于 2019-12-03 08:24:24
问题 I understand that it is best practise to import SASS/SCSS partials without using the leading underscore; e.g. @import 'normalize-scss/normalize'; // this imports ./normalize-scss/_normalize.scss My question for nerdy completeness is, are there any consequences if the file is imported using the underscore? @import 'normalize-scss/_normalize'; 回答1: No. If your file is _foo.scss, all of these imports have identical results as long as you don't have any ambiguous filenames (barring any side

Angular JS and partials

眉间皱痕 提交于 2019-12-03 06:34:29
问题 Is it possible to embed html page in another one in angular js? If so, how to do it? Here in their tutorial, the partial is not embedded in the page but it's like different page where you go when you click on one of the items. (see demo) 回答1: Yes, you can do it using ngInclude directive. See the docs and example here: https://docs.angularjs.org/api/ng/directive/ngInclude 回答2: @Wilt is right, but here is a more specific link and a code sample (from https://github.com/angular-ui/ui-router/wiki

How to implement erb partials in a non rails app?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 03:04:42
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? 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) Was trying to find out the same thing and didn't find much that was satisfying other than using the Tilt