0

I have created a groovy DSL extending the class BuilderSupport, and it looks like this right now:

def menu = new MenuBuilder().create {
  item "something.label" : "something"
  item "other.label" : "other"
  item "asd.label": "asd", {
     "test.label": "test"
  }
}

where create is not really a function, it's just a standard name for the root node, and item "X": "Y" represents a menu item where X is it's label and Y is the item's target controller.

The DSL is already working. My question is how can I make it so you can simply specify the DSL in a separate file and then load it when the Grails application is starting, similar to Grails's Bean's DSL and constraints's DSL.

The file would have only the following code inside it.

{
  item "something.label" : "something"
  item "other.label" : "other"
  item "asd.label": "asd", {
     "test.label": "test"
  }
}

Thanks for your attention

john
  • 1,156
  • 9
  • 22

1 Answers1

0

You could have the DSL specified in an external config file and load that external config in the main config.

The DSL would be available like all other configs

This answer should help: Grails - Cannot read externalized configuration values

Community
  • 1
  • 1
Lalit Agarwal
  • 2,354
  • 1
  • 14
  • 18