プロジェクト

全般

プロフィール

Vote #71988

完了

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

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Plugin API_20
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
20
version_id:
52
issue_org_id:
11105
author_id:
46901
assigned_to_id:
1
comments:
8
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
49
ステータス-->[Closed]

説明

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.


journals

If I insert code:

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

in redmine view near hook, it work fine, but in the hook It doesn't work.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
For example. init.rb code:

<pre>
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
</pre>

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

<pre>
<% 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!
</pre>

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:

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

Links appear inside tag "body":
<pre>
<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>
</pre>

I would like include these links in tag "head"
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Fixed in r9785.
--------------------------------------------------------------------------------
Merged in 2.0-stable.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Needs feedback,13456,<% content_for :header_tags do %> doesn't work inside hook
relates,Needs feedback,11527,content_for :header_tag not working within partials

Admin Redmine さんが3年以上前に更新

  • カテゴリPlugin API_20 にセット
  • 対象バージョン2.0.3_52 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0