Project

General

Profile

Actions

Defect #11105

closed

<% content_for :header_tags do %> doesn't work inside hook

Added by Vladimir Pitin almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
Normal
Category:
Plugin API
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Code:

<% content_for :header_tags do %>
  <%= stylesheet_link_tag :issue_hot_buttons_sidebar, :plugin => 'issue_hot_buttons_plugin'  %>
<% end %>

doesn't insert css link in head tag. This code is called from plugin's hook

<%= stylesheet_link_tag :issue_hot_buttons_sidebar, :plugin => 'issue_hot_buttons_plugin' %>
Inserts css link in body of html document.


Related issues

Related to Redmine - Defect #13456: <% content_for :header_tags do %> doesn't work inside hookNeeds feedback

Actions
Related to Redmine - Defect #11527: content_for :header_tag not working within partialsNeeds feedback

Actions
Actions #1

Updated by Vladimir Pitin almost 12 years ago

If I insert code:

<% content_for :header_tags do %>
  <%= stylesheet_link_tag :issue_hot_buttons_sidebar, :plugin => 'issue_hot_buttons_plugin'  %>
<% end %>

in redmine view near hook, it work fine, but in the hook It doesn't work.

Actions #2

Updated by Jean-Philippe Lang almost 12 years ago

  • Resolution set to Cant reproduce

Please, explain what you're doing exactly (eg. post the code of your hook class, or at least give the hook name).
Using <% content_for :header_tags do %> in a plugin view actually works as expected.

Actions #3

Updated by Vladimir Pitin almost 12 years ago

For example. init.rb code:

require 'redmine'

class Hooks < Redmine::Hook::ViewListener
    render_on :view_issues_show_details_bottom, :partial => 'assets', :layout => false
end

Redmine::Plugin.register :issue_hot_buttons do
    name 'Issue Hot Buttons Plugin'
    author 'Mike Kolganov, Thumbtack Inc.'
    description 'Plugin for Redmine that add buttons for often used actions to issue page'
    version '0.4.1'
    url 'https://github.com/mikekolganov/redmine-issue-hot-buttons'
end

app/views/issues/_assets.html.erb content is:

<% content_for :header_tags do %>
  <%= javascript_include_tag 'hot_buttons.js', :plugin => 'issue_hot_buttons' %>
  <%= stylesheet_link_tag 'hot_buttons.css', :plugin => 'issue_hot_buttons' %>
<% end %>

Test Test Test!

If I open any issue, I see "Test Test Test!", but links to "hot_buttons.js" and "hot_buttons.css" are absent.

If I modify code in app/views/issues/_assets.html.erb:

  <%= javascript_include_tag 'hot_buttons.js', :plugin => 'issue_hot_buttons' %>
  <%= stylesheet_link_tag 'hot_buttons.css', :plugin => 'issue_hot_buttons' %>

Links appear inside tag "body":

<link href="/plugin_assets/issue_hot_buttons/stylesheets/hot_buttons.css?1339038118" media="screen" rel="stylesheet" type="text/css">
<script src="/plugin_assets/issue_hot_buttons/javascripts/hot_buttons.js?1339107838" type="text/javascript"></script>

I would like include these links in tag "head"

Actions #4

Updated by Vladimir Pitin almost 12 years ago

  • Assignee set to Jean-Philippe Lang
Actions #5

Updated by Jean-Philippe Lang almost 12 years ago

  • Subject changed from Mechanism <% content_for :header_tags do %> doesn't work to Mechanism <% content_for :header_tags do %> doesn't work inside hook
  • Status changed from New to Confirmed
  • Resolution deleted (Cant reproduce)
Actions #6

Updated by Jean-Philippe Lang almost 12 years ago

  • Subject changed from Mechanism <% content_for :header_tags do %> doesn't work inside hook to <% content_for :header_tags do %> doesn't work inside hook
  • Status changed from Confirmed to Resolved
  • Target version set to 2.0.3
  • Resolution set to Fixed

Fixed in r9785.

Actions #7

Updated by Jean-Philippe Lang almost 12 years ago

  • Status changed from Resolved to Closed

Merged in 2.0-stable.

Actions #8

Updated by Go MAEDA over 9 years ago

  • Related to Defect #11527: content_for :header_tag not working within partials added
Actions

Also available in: Atom PDF