Method: Osheet::Workbook#use
- Defined in:
- lib/osheet/workbook.rb
#use(mixin) ⇒ Object
use a mixin to define its markup handlers (templates, partials, and styles) in your workbook scope all blocks in mixins will be instance eval’d in the workbook scope and should be written as such
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/osheet/workbook.rb', line 57 def use(mixin) # templates and partials are just blocks themselves so they just need to # be added to the workbook element # they will be instance eval'd when they get used (mixin.templates || []).each { |mt| template(*mt.args, &mt.build) } (mixin.partials || []).each { |mp| partial(*mp.args, &mp.build) } # styles not only need to be added to the workbook element, but # any build passed to the style needs to be instance eval'd (mixin.styles || []).each do |ms| StyleBuild.new(self, *ms.args, &ms.build).add do |build| instance_eval(&build) end end end |