2013-10-31 15 views
7

मैंने एक हैमल-आंशिक बनाया है जिसे मैं डिफ़ॉल्ट शीर्षलेख के रूप में उपयोग करना चाहता हूं। इसे प्रस्तुत करते समय मैं वैकल्पिक रूप से डिफ़ॉल्ट सामग्री के एक हिस्से को प्रतिस्थापित करने के लिए एक ब्लॉक देना चाहता हूं।रेल 4, वैकल्पिक ब्लॉक के साथ आंशिक/लेआउट प्रस्तुत करें haml

मैं कोशिश की है कई चीजों:

render partial: "partial", capture: do 
# Don't really know why I tried this, Syntax error ofcourse. 

render partial: "partial" do 
# 'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path. 

render layout: "partial" do 
# Works, but: 

render layout: "partial" 
# You invoked render but did not give any of :partial, :template, :inline, :file or :text option. 
# So, it always needs the block 

किसी भी अन्य विकल्प मैं के बारे में पता नहीं है?

उत्तर

13

जब आपको ब्लॉक की आवश्यकता होती है तो render layout: "" का उपयोग करें।

जब आप ब्लॉक का उपयोग नहीं करते हैं तो render partial: "" का उपयोग करें।

वे दोनों स्थानीय लोगों के साथ काम करते हैं और पूर्व-अंडरस्कोर फ़ाइल की तलाश करते हैं।

संबंधित मुद्दे