Questions tagged [view-helpers]

Use this tag for questions on ViewHelpers as used by the Fluid templating engine.

Viewhelpers are a part of Fluid. Fluid is a templating engine used primarily by TYPO3 and Neos.

ViewHelpers are special classes which build on base classes provided by Fluid. These classes can then be imported and used as part of the Fluid language.

More information:

414 questions
78
votes
6 answers

Where to put Ruby helper methods for Rails controllers?

I have some Ruby methods certain (or all) controllers need. I tried putting them in /app/helpers/application_helper.rb. I've used that for methods to be used in views. But controllers don't see those methods. Is there another place I should put them…
at.
  • 45,606
  • 92
  • 271
  • 433
48
votes
2 answers

How to call ApplicationController methods from ApplicationHelper

I want to provide csv links in a view and I placed the csv generating code in ApplicationHelper. However I'm getting this error: undefined method `send_data' for #<#:0x0000010151a070> referencing this: send_data content,…
David
  • 7,132
  • 6
  • 38
  • 61
26
votes
5 answers

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

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 …
ynkr
  • 20,186
  • 4
  • 30
  • 30
24
votes
4 answers

How to mock request object for rspec helper tests?

I've a view helper method which generates a url by looking at request.domain and request.port_string. module ApplicationHelper def root_with_subdomain(subdomain) subdomain += "." unless subdomain.empty? …
BuddhiP
  • 5,711
  • 2
  • 30
  • 48
19
votes
5 answers

Use view helpers in controllers in Zend Framework

I have a controller that is called with AJAX (sends JSON data), so I don't use a view. I need to use a personnal view helper to format my data, but in my controller. Is that possible ? Or maybe I am doing it wrong (maybe I should have a view, but…
Matthieu Napoli
  • 42,736
  • 37
  • 154
  • 239
19
votes
5 answers

How to add a view helper directory (zend framework)

I begin with ZF (1.9.7), and I want to use View Helpers from a library shared between all my projects. But I can't find how to add it directory to the helpers path. My herpers works fines when I put them in application's helpers path. Here is the…
Cédric Girard
  • 3,228
  • 7
  • 34
  • 50
19
votes
3 answers

Using helper methods while templating with Angular JS

Currently in the process of converting a website from its previous templating to Angular. In the previous templating process we were using we were able to call helper methods to display data correctly. For instance:
yaegerbomb
  • 1,126
  • 4
  • 22
  • 35
18
votes
3 answers

zend view helper with multiple methods?

class My_View_Helper_Gender extends Zend_View_Helper_Abstract { public function Gender() { // } } "The class method (Gender()) must be named identically to the concliding part of your class name(Gender).Likewise,the helper's file name…
luca
  • 34,346
  • 27
  • 81
  • 123
18
votes
4 answers

Rails: Is it possible to write view helpers with HAML syntax?

During refactoring it would be quite handy just to copy part of HAML template and paste it to helper's code. Currently in such cases 1) I have to rewrite that part of view from scratch 2) I have to use that verbose syntax like content_tag or…
Alexey
  • 8,424
  • 4
  • 55
  • 75
18
votes
2 answers

What is the best practice to create a custom helper function in php Laravel 5?

I have the default created_at date keep printing out as an MySQL format : 2015-06-12 09:01:26. I wanted to print it as my own way like 12/2/2017, and other formats in the future. I created a file called DataHelper.php and store it at…
cyb3rZ
  • 43,853
  • 82
  • 251
  • 430
16
votes
1 answer

how to capture a block in a helper's child class?

I'm trying to do the following: module ApplicationHelper class PModuleHelper include ActionView::Helpers::TagHelper def heading(head = "", &block) content = block_given? ? capture(&block) : head.to_s content_tag :h3,…
Markus
  • 5,201
  • 2
  • 43
  • 61
15
votes
4 answers

Force Canonical to use HTTPS

I want my customer section to be https, e.g. registration, login, personal details, order details, etc. I have set up my route to include the https scheme (I can access the customer section via https) but I cannot force my links to use https:
14
votes
8 answers

Add an 'active' class to all active links in rails?

Basically, I have a lot of code that looks like this: link_to t('.profile'), business_path(@business), class: '#{'active' if current_page? business_path(@business)}' which isn't very DRY. I was wondering if anyone knows a good way to modify the…
Dylan Karr
  • 2,594
  • 4
  • 16
  • 27
14
votes
2 answers

Unpermitted parameters in rails 4

I read about collection_check_boxes but I don't understand how can I set the checked values. I have the following model: class Objective < ActiveRecord::Base has_many :indicators has_many :objective_children, class_name: "Objective",…
12
votes
3 answers

Rails :confirm modifier callback?

I want to call a javascript function that will be conditional upon a user's response to the confirm box. For example, I have the following anchor: <%= link_to 'Sign Out', destroy_session_path, confirm: 'Are you sure that you would like to sign…
1
2 3
27 28