Skip to content

Instantly share code, notes, and snippets.

@steveh
Forked from anonymous/detect-mustache.rb
Created February 18, 2013 19:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveh/4980034 to your computer and use it in GitHub Desktop.
Save steveh/4980034 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
fn = ARGV[0]
if !fn
puts "Usage: #{$0} file.mustache"
puts
exit
end
fields = []
File.read(fn).split("\n").each do |l|
if l =~ /{{{(.+?)}}}/ || l =~ /{{(.+?)}}/
next if $1[0,1] == '/'
field = $1
field = field[1..-1] if field[0,1] == '#'
field = field[1..-1] if field[0,1] == '^'
fields << field
end
end
puts fields.sort.uniq.join("\n")
puts
@aalermi
Copy link

aalermi commented Feb 18, 2013

!/usr/bin/env ruby

fn = ARGV[0]

if !fn
puts "Usage: #{$0} file.mustache"
puts
exit
end

fields = []
File.read(fn).split("\n").each do |l|
if l =~ /{{{(.+?)}}}/ || l =~ /{{(.+?)}}/
next if $1[0,1] == '/'
field = $1

field = field[1..-1] if field[0,1] == '#'
field = field[1..-1] if f

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