-
-
Notifications
You must be signed in to change notification settings - Fork 20
Build Template pipelines.
Cheikh Seck edited this page Sep 12, 2017
·
3 revisions
- Click on
Template pipelines
within your project tree.
- Click on the yellow save button or use (ctrl-s | cmd-s)
- Multi-purpose text field. Text used to search for a Pipeline and new pipeline name.
- Click on the button with the
+
(plus) symbol to create a new pipeline ( with multi-purpose field filled). - Click on the button with search symbol to search for a pipeline ( with multi-purpose field filled). You can always use (ctrl-f | cmd-f)
Template pipeline.
name - Specifies the name of the function. Please keep in mind that usage of this function outside of templates requires the `net_` added to name because GoS appends that prefix to avoid any method redeclaration. If you desire to write methods for strict usage outside of template files we recommend writing a normal Go package and importing it with the `<import/>` tag or creating another Go file within your project directory.
return - The return type of the function. Ie: string,bool or a custom struct `DemoGos`
var - This is a comma delimited string of the variables you wish this function to have. Say we need a function that has two parameters `param1 string, param2 string` it will be declared `param1,param2`. Before using the variable make sure its type is defined within the method. For example to log `param1` the call would be `fmt.Println(param1.(string))`
**InnerXml - This contains your method declarations. GoS will wrap up the inner xml data with your method attributes to create a Go func
Test case : Send email pipeline. The variables set in the var tag need their type declared during use. The example below we will declare a function that sends emails and returns a bool
.
<gos>
...
<method name="sendEmail" var="to,from" return="bool">
go fmt.Println("Send Email -> " + to.(string) + " ->" + from.(string))
return true
</method>
...
</gos>
... Output by GoS :
//Generated template method
func net_sendEmail(args ...interface{}) bool
Now we will create a template class that will output a Bootstrap alert if an email is sent and an error if not.
{{ if "from" | sendEmail "to" }}
{{Bootstrap_alert /{`Strong`:`Success`,`Type`:`success`, `Text` : `Email Sent`}/ }}
{{else}}
{{Bootstrap_alert /{`Strong`:`Error`,`Type`:`danger`, `Text` : `Please Login`}/ }}
{{end}}
Do not let the |
scare you (known as pipe), in our case the function parameter "from"
becomes the last parameter of the function call and ones following the method name the first parameters, ordered in the way they are inputted. hence : LastParam | functionName param1 param2...
.
Another way to invoke your function is :
{{if sendEmail "to" "from" }}
{{Bootstrap_alert /{`Strong`:`Success`,`Type`:`success`, `Text` : `Email Sent`}/ }}
{{end}}
That Easy!!!!!!