Emacs组织模式:在另一个src块中使用src块的结果
有src块吗Emacs组织模式:在另一个src块中使用src块的结果,emacs,org-mode,Emacs,Org Mode,有src块吗 #+NAME: gdt #+BEGIN_SRC ruby :var date="14-05-2018" require 'active_support/all' table_header_days = [] today = Date.parse(date) 0.upto(7 - today.wday) do |n| table_header_days.push("#{(today + n.days).day} #{(today + n.days).strf
#+NAME: gdt
#+BEGIN_SRC ruby :var date="14-05-2018"
require 'active_support/all'
table_header_days = []
today = Date.parse(date)
0.upto(7 - today.wday) do |n|
table_header_days.push("#{(today + n.days).day} #{(today + n.days).strftime('%a')}")
end
[['', table_header_days, ''].flatten, nil, ['row 1'], ['row 2'], ['row 3'], ['row 4']]
#+END_SRC
#+BEGIN_SRC ruby :noweb eval :exports table
<<gdt("14-05-2018")>>
#+END_SRC
它像桌子一样输出
#+RESULTS: gdt
| | 14 Mon | 15 Tue | 16 Wed | 17 Thu | 18 Fri | 19 Sat | 20 Sun | |
|-------+--------+--------+--------+--------+--------+--------+--------+---|
| row 1 | | | | | | | | |
| row 2 | | | | | | | | |
| row 3 | | | | | | | | |
| row 4 | | | | | | | | |
我想在其他src块中使用这个src块
#+NAME: gdt
#+BEGIN_SRC ruby :var date="14-05-2018"
require 'active_support/all'
table_header_days = []
today = Date.parse(date)
0.upto(7 - today.wday) do |n|
table_header_days.push("#{(today + n.days).day} #{(today + n.days).strftime('%a')}")
end
[['', table_header_days, ''].flatten, nil, ['row 1'], ['row 2'], ['row 3'], ['row 4']]
#+END_SRC
#+BEGIN_SRC ruby :noweb eval :exports table
<<gdt("14-05-2018")>>
#+END_SRC
我做错了什么?在noweb“调用”的
标记中,唯一可以使用的是代码ID,即要替换它的块的名称。特别是,不能像这样传递参数
尝试将第二个块更改为:
#+BEGIN_SRC ruby :noweb eval :exports table :var date="14-05-2018"
<<gdt>>
#+END_SRC
#+BEGIN#SRC ruby:noweb eval:exports table:var date=“14-05-2018”
#+结束(SRC)