// adds a transform function to the transporter pipeline
// transform takes one argument, which is a path to a transformer file.
adds a transform function to the transporter pipeline
transform takes one argument, which is a path to a transformer file.
// adds a transform function to the transporter pipeline // transform takes one argument which is a path to a transformer file .
func (js *JavascriptBuilder) transform(token string, node Node, call otto.FunctionCall) (Node, error) {
	transformer, err := js.findNode(token, call.Argument(0))
	if err != nil {
		return node, fmt.Errorf("save error, %s", err.Error())
	}
	filename := transformer.Extra.GetString("filename")
	if filename == "" {
		return node, fmt.Errorf("transformer config must contain a valid filename key")
	}
	if !filepath.IsAbs(filename) {
		transformer.Extra["filename"] = filepath.Join(js.path, filename)
	}
	root := js.nodes[node.RootUUID]
	parent, err := root.Find(node.UUID)
	if err != nil {
		return node, fmt.Errorf("transformer error, %s", err.Error())
	}
	parent.Add(&transformer)
	js.nodes[root.UUID] = root
	return transformer, nil
}
func ( js * JavascriptBuilder ) transform ( token string , node Node , call otto . FunctionCall ) ( Node , error ) { transformer , err := js . findNode ( token , call . Argument ( 0 ) ) if err != nil { return node , fmt . Errorf ( " " , err . Error ( ) ) } filename := transformer . Extra . GetString ( " " ) if filename == " " { return node , fmt . Errorf ( " " ) } if ! filepath . IsAbs ( filename ) { transformer . Extra [ " " ] = filepath . Join ( js . path , filename ) } root := js . nodes [ node . RootUUID ] parent , err := root . Find ( node . UUID ) if err != nil { return node , fmt . Errorf ( " " , err . Error ( ) ) } parent . Add ( & transformer ) js . nodes [ root . UUID ] = root return transformer , nil }
adds a transform function to the transporter pipeline
transform takes one argument, which is a path to a transformer file.
adds a transform function to the transporter pipeline transform takes one argument which is a path to a transformer file .