2
특정 사용자 정의 HTML 태그를 찾는 erb 파일을 스캔하고 (이 부분을 완료했습니다) 렌더링하기 전에이 태그를 가로 채서 html 출력을 바꿉니다. RAILS에서 이런 종류의 활동과 관련된 정보를 찾을 수 없습니다. 어쩌면 나는 올바른 곳을보고 있지 않을 것입니다.레일을 오버라이드하여 메서드를 렌더링하고 내용을 바꿉니다.
특정 사용자 정의 HTML 태그를 찾는 erb 파일을 스캔하고 (이 부분을 완료했습니다) 렌더링하기 전에이 태그를 가로 채서 html 출력을 바꿉니다. RAILS에서 이런 종류의 활동과 관련된 정보를 찾을 수 없습니다. 어쩌면 나는 올바른 곳을보고 있지 않을 것입니다.레일을 오버라이드하여 메서드를 렌더링하고 내용을 바꿉니다.
어쩌면 당신 같은 STH 할 수있는 :
class PostsController < ApplicationController
acts_as_special
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html { my_renderer }
end
end
end
및 플러그인 또는 STH 쓰기 :
이# Module to Extend a given Controller with the acts_as_special methods
module MyRenderer
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def acts_as_special
include MyRenderer::InstanceMethods
end
end
module InstanceMethods
def my_renderer
.. do sth with the code ....
render :template => ...
end
end
end
ActionController::Base.class_eval do
include MyRenderer
end
아니라 당신이 플러그인을 작성해야 해달라고을 YUST 당신은 "당신의"렌더링 확인해야 메서드를 사용할 수 있습니다.
다른/더 나은 방법이 있으면 알려 주시기 바랍니다.