首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何拆散档案?

如何拆散档案?
EN

Stack Overflow用户
提问于 2013-05-11 09:18:01
回答 1查看 196关注 0票数 1

我试图向Octopress Rakefile添加一些rake任务,我想将这些任务放到另一个子rakefile中,但是当我导入子rakefile时,它们无法访问rakefile顶部的常量。

我正在导入儿童rakefile文件,并:

代码语言:javascript
复制
Dir.glob('rakefiles/*.rake').each { |r| import r }

这是我无法在子文件中读取的配置类型:

代码语言:javascript
复制
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‘

EN

回答 1

Stack Overflow用户

发布于 2013-05-11 09:45:03

您需要使用类变量,如

代码语言:javascript
复制
@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')

或常量

代码语言:javascript
复制
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')
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16495599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档