helpers

System.Web.Helpers not found in VS2015

送分小仙女□ 提交于 2019-11-28 03:00:37
问题 I'm trying to add some JSON parsing to the C# code in VS2015 but I can't find: System.Web.Helpers as the MS documentation suggests. I've looked at other people's questions of a similar nature (almost all on earlier versions) and the answers all say to add it in the Assemblies / Framework dialog. The problem is it doesn't appear in that dialog, nor do many of the other things I see people talking about. I would really appreciate any help on fixing this. Here is the list I have access to: Edit:

Rails 3: @template variable inside controllers is nil

本秂侑毒 提交于 2019-11-28 00:03:11
i've started using rails 3 beta3 and I have see that the @template variable inside controllers is nil. How I can call helpers methods inside a controller? Thx Dmitry Naumov Use the view_context method instead of @template . This is because in Rails 3 the new AbstractController was introduced. You can read more here: http://apidock.com/rails/AbstractController/Rendering/view_context 来源: https://stackoverflow.com/questions/3300582/rails-3-template-variable-inside-controllers-is-nil

Rails 3.1: Better way to expose an engine's helper within the client app

做~自己de王妃 提交于 2019-11-27 19:22:42
I have found a few articles addressing the issue of helpers within an engine not being accessible to the consuming (parent) application. To make sure we are all on the same page, let's say we have this: module MyEngine module ImportantHelper def some_important_helper ...do something important... end end end If you look at the rails engine documentation in the "Isolated engine's helpers" (L293), it says: # Sometimes you may want to isolate engine, but use helpers that are defined for it. # If you want to share just a few specific helpers you can add them to application's # helpers in

Calling helper method from Rails 3 controller

*爱你&永不变心* 提交于 2019-11-27 14:36:49
问题 Is it possible to call helper methods from controller? If yes how to do this in Rails 3? 回答1: view_context.some_helper_method 回答2: You can either include the helper module in the controller, or define the helper as a controller method and mark it as a helper via helper_method :method_name . class FooHelper def bar ... end end class QuxsController include FooHelper end or class QuxsController private def bar ... end helper_method :bar end 回答3: This is working if some one wants to use

SessionsHelper in railstutorial.org: Should helpers be general-purpose modules for code not needed in views?

淺唱寂寞╮ 提交于 2019-11-27 13:44:18
问题 railstutorial.org has a suggestion which strikes me as a little odd. It suggests this code: class ApplicationController < ActionController::Base protect_from_forgery include SessionsHelper end The include SessionsHelper makes the methods available from ApplicationController , yes, but it makes them available in any view, as well. I understand that authentication/authorization is cross-cutting, but is this really the best place? That seems to me to be potentially too broad of a scope. Putting

Rails: Preserving GET query string parameters in link_to

妖精的绣舞 提交于 2019-11-27 11:39:23
I have a typical search facility in my app which returns a list of results that can be paginated, sorted, viewed with a different records_per_page value, etc. Each of these options is controlled by parameters in the query string. A simplified example: /search?q=test&page=2 Now say I need to display a set of links that set records_per_page value to 10, 20, 30. Each link must include the existing query parameters, which can be a very long set, plus a new per_page parameter. /search?q=test&page=2& ... &per_page=10 /search?q=test&page=2& ... &per_page=20 /search?q=test&page=2& ... &per_page=30 Is

Rails- nested content_tag

只愿长相守 提交于 2019-11-27 10:43:07
I'm trying to nest content tags into a custom helper, to create something like this: <div class="field"> <label>A Label</label> <input class="medium new_value" size="20" type="text" name="value_name" /> </div> Note that the input is not associated with a form, it will be saved via javascript. Here is the helper (it will do more then just display the html): module InputHelper def editable_input(label,name) content_tag :div, :class => "field" do content_tag :label,label text_field_tag name,'', :class => 'medium new_value' end end end <%= editable_input 'Year Founded', 'companyStartDate' %>

How do I make global helper functions in laravel 5?

风流意气都作罢 提交于 2019-11-27 05:17:14
问题 If I wanted to make a currentUser() function for some oauth stuff I am doing where I can use it in a view or in a controller (think rails, where you do helper_method: current_user in the application controller). Everything I read states to create a helpers folder and add the function there and then that way you can do Helpers::functionName Is this the right way to do this? Whats the "laravel way" of creating helper functions that can be used in blade templates and controllers? 回答1: Create a

conditional on last item in array using handlebars.js template

北慕城南 提交于 2019-11-27 05:15:12
问题 I am leveraging handlebars.js for my templating engine and am looking to make a conditional segment display only if it is the last item in array contained in the templates configuration object. { columns: [{<obj>},{<obj>},{<obj>},{<obj>},{<obj>}] } I've already pulled in a helper to do some equality/greater/less-than comparisons and have had success identifying the initial item this way but have had no luck accessing my target array's length. Handlebars.registerHelper('compare', function

Rails 3.1: Better way to expose an engine's helper within the client app

自闭症网瘾萝莉.ら 提交于 2019-11-27 04:22:05
问题 I have found a few articles addressing the issue of helpers within an engine not being accessible to the consuming (parent) application. To make sure we are all on the same page, let's say we have this: module MyEngine module ImportantHelper def some_important_helper ...do something important... end end end If you look at the rails engine documentation in the "Isolated engine's helpers" (L293), it says: # Sometimes you may want to isolate engine, but use helpers that are defined for it. # If