我试图向Octopress Rakefile添加一些rake任务,我想将这些任务放到另一个子rakefile中,但是当我导入子rakefile时,它们无法访问rakefile顶部的常量。
我正在导入儿童rakefile文件,并:
Dir.glob('rakefiles/*.rake').each { |r| import r }这是我无法在子文件中读取的配置类型:
public_dir = "public" # compiled site directory
source_dir = "source" # source file directory
blog_index_dir = 'source' # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')以下是错误:
拉克流产了!main:Object的未定义局部变量或方法`source_dir‘
发布于 2013-05-11 09:45:03
您需要使用类变量,如
@public_dir = "public" # compiled site directory
@source_dir = "source" # source file directory
@blog_index_dir = 'source' # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')或常量
PUBLIC_DIR = "public" # compiled site directory
SOURCE_DIR = "source" # source file directory
BLOG_INDEX_DIR = 'source' # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')https://stackoverflow.com/questions/16495599
复制相似问题