質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top