Sha256: 3d48a79f264c86479083f21e62307e889b7ee90fcc9eceb387cffd00550e0ea9

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

class FreemarkerTemplateEngine < VraptorScaffold::Base

  def self.source_root
    File.join(File.dirname(__FILE__), "templates", "freemarker")
  end

  def initialize(project_path, options)
    super
    self.destination_root=(project_path)
    @project_path = project_path
    @options = options
  end

  def configure
    directory("macros", File.join(Configuration::WEB_APP, "macros"))
    template("../decorators.erb", File.join(Configuration::WEB_INF, "decorators.xml"))
    template("main.ftl.erb", File.join(Configuration::WEB_INF, decorators_path, "main.ftl"))
    #copy_file("main.ftl", File.join(Configuration::WEB_INF, decorators_path, "main.ftl"))
    directory("infrastructure", infra_path)
    append_freemarker_servlet
  end

  def extension
    "ftl"
  end

  def decorators_path
    File.join "views", "decorators"
  end

  def package
    file = File.join(@project_path, Configuration::FILENAME)
    package = YAML.load_file(file)['package']
  end

  private
  def append_freemarker_servlet
    file = File.join(Configuration::WEB_INF, "web.xml")
    template = File.join FreemarkerTemplateEngine.source_root, "freemarker-web.xml"
    inject_into_file(file, File.read(template), :before => "</web-app>", :verbose => false)
  end

  def infra_path
    File.join Configuration::MAIN_SRC, package.gsub(".", File::Separator), "infrastructure"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vraptor-scaffold-1.3.0 lib/vraptor-scaffold/generators/app/freemarker_template_engine.rb