Last updated by iankwalter 1 year ago
Go to your project root and run the command:
grails install-plugin spawn
You'll probably want to base your templates around the default Grails templates. They're a good starting point. In order to get them, run:
grails install-templates
The default templates will then be placed in src > templates > scaffolding
Last updated by iankwalter 1 year ago
Spawn plugin allows you to specify a specific template for a domain class. This way you can have multiple templates within your
application and assign them to whichever domain class you would like to use them with. You simply add a folder containing the
templates to src > templates > scaffolding >
templateName. Then you add the line 'static templateName = "templateName";' to
your domain class. Then you would use the command 'grais spawn-all
domainClass (+)' to generate the contoller and views as you would
with the default generaiton scripts.
Last updated by iankwalter 1 year ago
= Instructions
- Add a static variable to your domain class called "SPAWN" which will contain a XML configuration.
- IE: static def SPAWN = """
<Template default="template-two">
</Template>
"""
- Set the default equal to the name of the template you want to use for that domain class.
- If you want to use the base scaffolding directory, set the default to "base"
2. If you want to specify which templates are used based on each view, then add a "Files" section to the template XML and specify the file name and which directory it's in. Make sure the template .gsp files are actually in the directory you specify!
- IE: <Template default="template-two">
<Files>
<File name="list">base</File>
<File name="extraView>template-three</File>
</Files>
</Template>
3. If you're creating a seperate template from the base template:
- In your grails application folder, create a new folder in src > templates > scaffolding. Name this folder the same as the default you set in the XML configuration.
4. Copy the base templates into your newly created template folder and modify them as you wish.
5. Once you want to generate artifacts, run the scripts 'spawn-all', 'spawn-controller', or 'spawn-views' like you would with the default grails generate scripts.
- IE: grails spawn-all org.walter.example.ExampleTwo
= Roadmap
- Features in Current Release (0.2)
- Ability to specify default template directory
- Ability to specify individual templates files in a different directory than the default
- Ability to add attributes to "Field" XML element and have them accessible in the renderEditor.template.
- Features in Next Release (0.3)
- Ability to add attributes to "Field" XML element and have them accessible in the scaffolding view templates (IE: create.gsp)
- Features in Future Release (0.5)
- Ability to specify the template directory to use through the spawn-views command.
IE: grails spawn-views example.MyDomain -templates2
Where "templates2" is the directory name of the alternative template files.
Last updated by admin 1 year ago