Created
April 25, 2017 11:41
-
-
Save ManWithBear/dd0dfa62d0dd2d3e1c64a0c5216a9d4f to your computer and use it in GitHub Desktop.
Generate files from provided template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
ruby liquidGenerator.rb {path to template}/extension.swift.liquid
Will generate file:
{path to template}/extension.swift