Sinatra 在 Sprockets 中应用 Spine 的技巧

hpyhacking · August 30, 2012 · 2020 hits

通常我希望将 Spine.Stack 中包含的 Controller 都单独存放,毕竟有了 Sprockets 组织 JavaScript 的依赖关系是件非常 Easy 的事情了。

app/index.coffee中通常会有

#= require_tree ./controllers

那么如果想要让controllers/stack.coffee优先于controllers/stack/piece.coffee加载,只需要在stack.coffee的头部添加

#= require_tree ./stack 即可

这样 Sprockets 解析到stack.coffee的时候会去先解析下级的stack目录,而不是默认的走index.coffee中的 require_tree 规则,require_tree 是递归逐层向子级目录加载文件。

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.