Question

I need to write a custom syntax for a template engine.

Like this:

https://github.com/pietbrauer/cocoapods-generate-command/blob/master/README.md

Example from the README:

# template
git :init

# questions
prefix = ask('What prefix should be used for your files?')
prefix = prefix.uppercase

# add pods
pod 'AFNetworking', '~> 2.0.0'

pod_group :SampleTests do
  pod 'OCMock'
end

Whats the best approach for this? Would one write a custom DSL or a parser to execute ruby code.

Était-ce utile?

La solution

For the example you posted, I'd definitely look at writing an internal Ruby DSL. The syntax looks like valid Ruby code to me, it'll be as easy as it gets.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top