Exemplo n.º 1
0
func init() {
	p2.RegisterFilter("field", func(ctx *p2.ExecutionContext, in *p2.Value, param *p2.Value) (out *p2.Value, err *p2.Error) {
		if nil == in.Interface() || in.String() == "" {
			return nil, ctx.Error("field argument must is string", nil)
		}
		return p2.AsValue(revel.NewField(in.String(), ctx.Public)), nil
	})
}
Exemplo n.º 2
0
func init() {
	revel.TemplateFuncs["castjob"] = func(job cron.Job) *jobs.Job {
		return job.(*jobs.Job)
	}
	p2.RegisterFilter("castjob", func(ctx *p2.ExecutionContext, in *p2.Value, param *p2.Value) (out *p2.Value, err *p2.Error) {
		job := in.Interface().(*jobs.Job)
		return p2.AsValue(job), nil
	})
}