Sha256: df70e84c740853faab0c37f740d6636db3221cfc286ab0f69ac2adf715d0d348
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Lhj class Command class CodeTemplate < Command self.summary = '生成源码模板' self.description = '生成的代码模板' CODE_TEMPLATE_INDEX = [{ name: 'dispatch Source 模板', template: 'dispatch_source.erb' }, { name: '另一个 模板', template: 'fffaaa' }, { name: '代码模板', template: 'fffbbb' }].freeze def initialize(argv) @cli = HighLine.new super end def handle CODE_TEMPLATE_INDEX.each_index do |i| puts "#{i}.#{CODE_TEMPLATE_INDEX[i][:name]}".yellow end idx = @cli.ask('请选择查看代码模板: '.green).strip.to_i item = CODE_TEMPLATE_INDEX[idx] template_name = item[:template] template_str = render_template(template_name) puts template_str end def render_template(template_name) temp_str = File.read(File.join(File.dirname(__FILE__), 'template', template_name)) Lhj::ErbFormatter::Service.new(self).render_template(temp_str) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lhj-tools-0.1.36 | lib/lhj/command/code/code_template.rb |