Skip to content

Instantly share code, notes, and snippets.

@ManWithBear
Created April 25, 2017 11:41
Show Gist options
  • Save ManWithBear/dd0dfa62d0dd2d3e1c64a0c5216a9d4f to your computer and use it in GitHub Desktop.
Save ManWithBear/dd0dfa62d0dd2d3e1c64a0c5216a9d4f to your computer and use it in GitHub Desktop.
Generate files from provided template
require 'liquid'
require 'fileutils'
input_file = File.absolute_path(ARGV[0])
@template = Liquid::Template.parse(File.open(input_file, "r").read)
renderedTemplate = @template.render()
extn = File.extname(input_file)
output_file = File.dirname(input_file) + "/" + File.basename(input_file, extn)
File.open(output_file, "w") {|f| f.write(renderedTemplate) }
@ManWithBear
Copy link
Author

ManWithBear commented Apr 25, 2017

Usage:
ruby liquidGenerator.rb {path to template}/extension.swift.liquid
Will generate file:
{path to template}/extension.swift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment