`
xhanxhanxhan
  • 浏览: 206048 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Embeded Blocks for Rails Erb

    博客分类:
  • RUBY
阅读更多
費了幾乎兩個小時搞定這問題。很干
不過也終於解開個超級大謎團,為什麼類似
<% list_as_tree @root  do |item| %>
<div class="bubbleInfo">
<div class="trigger"><%= item.name %></div>
<div class="popup">
<%= addition_fun item %>
</div>
</div>    
<% end %> 
這樣的代碼能輸出內容呢。
原因很簡單,concat 魔法效果,而我就因為這個漏了這個函數浪費了近乎兩小時青春呀。

如果你使用 block.call(*p) 運行到這一步就會把運行結果輸出到erb中。
而如果使用了 capture ,他返回的是運行後的內容 而不乎自行添加到erb文件中,這時候就應該使用 concat 來輸出需要的內容了。

33:       def capture(*args, &block)
34:         # Return captured buffer in erb.
35:         if block_called_from_erb?(block)
36:           with_output_buffer { block.call(*args) }
37:         else
38:           # Return block result otherwise, but protect buffer also.
39:           with_output_buffer { return block.call(*args) }
40:         end
41:       end

      # Use an alternate output buffer for the duration of the block.
      # Defaults to a new empty string.
      def with_output_buffer(buf = '') #:nodoc:
        self.output_buffer, old_buffer = buf, output_buffer
        yield
        output_buffer
      ensure
        self.output_buffer = old_buffer
      end

這裡不過還是弄不清楚 block.call 的工作原理 。等自己哪天牛逼了再回頭解決
分享到:
评论

相关推荐

    Image Processing for Embedded Devices.pdf

    从给定文件信息中,我们可以提取有关嵌入式设备中图像处理的知识点。首先,文件标题指出本书涉及的内容包括从CFA数据到图像/视频编码的过程。CFA(Color Filter Array)数据是指彩色滤镜阵列数据,这是数字成像中...

    automotive embeded system

    this is a book describing the princple, the development process of the automotive embeded systems. by this book, our can perceive the most advanced and basic technologies of the automotive electronic ...

    嵌入式系统课件[Embeded System]

    这个名为"嵌入式系统课件[Embeded System]"的压缩包文件,显然是为学习和教学嵌入式系统知识而准备的。下面将详细阐述嵌入式系统的概念、特点、应用以及学习它的必要性。 嵌入式系统,顾名思义,是嵌入到特定设备或...

    嵌入式系统(embeded system)

    ### 嵌入式系统的规范与设计 #### 引言 嵌入式系统是指那些集成在机械或电气系统内部、执行特定功能的计算机系统。它们广泛应用于汽车、医疗设备、移动电话、数字电视等众多领域。《嵌入式系统的规范与设计》一文...

    c-embeded-system-learning.rar_Embeded Systems

    在“c-embeded-system-learning.rar_Embeded Systems”这个压缩包中,我们可以找到两个文件,一个是核心的学习资料“c-embeded-system-learning.pdf”,另一个可能是资源链接或参考信息的文本文件“www.pudn.com.txt...

    Embeded wizard辅助工具

    《Embeded Wizard辅助工具详解与应用》 在嵌入式系统开发中,界面设计和本地化处理是一项重要的任务。为了简化这一过程,一种名为“Embeded Wizard”的工具应运而生,它允许开发者创建和管理丰富的图形用户界面。...

    embeded linux primer 2nd

    this book guides you embeded development.

    overview of hypervisor for embeded systems.pdf

    由于本文档是关于嵌入式系统中虚拟化技术特别是虚拟机监控器(Hypervisor)的概述,因此首先需要理解虚拟化以及虚拟机监控器的基本概念,随后探讨嵌入式系统中的虚拟化应用,以及相关的安全问题。...

    embeded cd

    在这个上下文中,描述“embeded 090147372_book_WiinCE_for_Embest_EduKit2410”可能是指一本关于嵌入式技术的电子书,特别是针对WiinCE(Windows Embedded Compact)系统,该系统是微软为小型设备开发的一个实时...

    windows embeded compact 7

    win CE7安装包,安装时间比较长,需要耐心等待。

    Embedded Coder Support Package for TI C2000 Processors.pdf

    知识点一:Embedded Coder Support Package for Texas Instruments C2000 Processors介绍 Texas Instruments C2000系列处理器是针对实时控制应用设计的高性能数字信号处理器。针对这些处理器,MathWorks公司推出了...

    Embedded Image Processing on the TMS320C6000 DSP (Part 1)

    基于TI DSP C6000 的嵌入式图像处理 一共三个压缩卷,这是第一个

    EW字符文件转换器(Embeded wizard辅助工具)

    《EW字符文件转换器与Embeded Wizard辅助工具详解》 在嵌入式系统开发中,Embeded Wizard是一款广泛使用的图形用户界面(GUI)设计工具,它允许开发者创建丰富的交互式界面,而无需深入掌握底层编程语言。然而,在...

    embeded_timer.rar_embeded c++_嵌入式超时

    "embeded_timer.rar"这个压缩包文件显然包含了关于如何在C++环境中实现嵌入式系统的定时器超时保护功能的相关资料。让我们深入探讨一下这个主题。 嵌入式C++是C++语言的一个子集,它被优化用于嵌入式系统的编程。...

    Linux Driver Development for Embedded Processors, 2nd Edition.pdf

    Embedded systems have become an integral part of our daily life. They are deployed in mobile devices, networking infrastructure, home and consumer devices, digital signage, medical imaging, ...

    Desigining Embeded Software

    Designing Embeded Hardware

    使用embeded tomcat进行嵌入式javaee开发-启动tomcat

    在JavaEE开发中,使用内嵌的Tomcat服务器(通常称为embeded Tomcat)是一种常见的实践,它允许开发者在本地环境中快速、方便地测试和调试应用程序,而无需手动配置独立的服务器实例。本文将深入探讨如何使用embeded ...

    embeded system考古題

    embeded system一些練習題,助有要考試的人順利啦啦啦啦

Global site tag (gtag.js) - Google Analytics