| 84 | } |
| 85 | |
| 86 | func transform(ctx *transformContext) (bool, error) { |
| 87 | changed := false |
| 88 | |
| 89 | // registry is a map of functions defined in rain.go |
| 90 | for path, fn := range registry { |
| 91 | for found := range s11n.MatchAll(ctx.nodeToTransform, path) { |
| 92 | nodeParent := node.GetParent(found, ctx.nodeToTransform, nil) |
| 93 | nodeParent.Parent = ctx.parent |
| 94 | c, err := fn(&directiveContext{found, ctx.rootDir, ctx.t, nodeParent, ctx.fs, ctx.baseUri}) |
| 95 | if err != nil { |
| 96 | config.Debugf("Error packaging template: %s\n", err) |
| 97 | return false, err |
| 98 | } |
| 99 | |
| 100 | changed = changed || c |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | return changed, nil |
| 105 | } |
| 106 | |
| 107 | // processRainSection returns true if the Rain section of the template existed |
| 108 | // The section is removed by this function |