문제

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