func RunFieldProcessor(c *cli.CliConf) { fp := &FieldsProcessor{ CliConf: c, Env: process.NewEnv(), } fp.Load() }
func RunFieldProcessor(c *cmd.Context) { fp := &FieldsProcessor{ CliConf: cli.NewCliConf(c), Env: process.NewEnv(), } fp.Load() }
func RunPlainProcessor(c *cmd.Context) { p := &PlainProcessor{ CliConf: cli.NewCliConf(c), Env: process.NewEnv(), } err := p.Validate() if err != nil { log.Fatal(err) } p.Run() }
func RunPlainProcessor(c *cli.CliConf) { p := &PlainProcessor{ CliConf: c, Env: process.NewEnv(), } err := p.Validate() if err != nil { log.Fatal(err) } p.Run() }
func TestFrontmatter(t *testing.T) { Convey("Read should partition the file into frontmatter and template", t, func() { s := ` --- names: - Batman - Superman - Green Lantern --- <ul> {{ range .names }} <li>By {{ . }}</li> {{ end }} </ul> ` reader := bufio.NewReader(bytes.NewBufferString(s)) portions := &Portions{} err := portions.Read(reader) So(err, ShouldBeNil) env := process.NewEnv() tpl, err := env.CreateTemplate(s) So(err, ShouldBeNil) buf := bytes.NewBufferString("") tpl.Execute(buf, env.ToMap()) rendered := buf.String() So(err, ShouldBeNil) So(strings.Contains(rendered, "Batman"), ShouldBeTrue) So(strings.Contains(rendered, "Superman"), ShouldBeTrue) So(strings.Contains(rendered, "Green Lantern"), ShouldBeTrue) }) Convey("Read should partition the file into frontmatter and template", t, func() { s := ` --- 1 --- 2 ` reader := bufio.NewReader(bytes.NewBufferString(s)) portions := &Portions{} err := portions.Read(reader) So(err, ShouldBeNil) So(portions, ShouldNotBeNil) So(portions.FrontMatter, ShouldEqual, "1") So(portions.Template, ShouldEqual, "2") }) }
// Cli provides the context (flags and values) with which to run a process for // generating over a front matter file. func RunFrontMatterProcessor(c *cli.CliConf) { p := &FrontMatterProcess{ CliConf: c, portions: &Portions{}, Env: process.NewEnv(), } err := p.Validate() if err != nil { log.Fatal(err) } p.Run() }
// Cli provides the context (flags and values) with which to run a process for // generating over a front matter file. func NewFrontMatterProcessor(c *cmd.Context) { p := &FrontMatterProcess{ CliConf: cli.NewCliConf(c), portions: &Portions{}, Env: process.NewEnv(), } err := p.Validate() if err != nil { log.Fatal(err) } p.Run() }
func RunDocFinder(c *cli.CliConf) { df := &DocFinder{ CliConf: c, Env: process.NewEnv(), } defer func() { err := recover() if err != nil { df.Env.ShowEnvironment(os.Stdout) fmt.Println(err) } }() err := df.Run() if err != nil { df.Env.ShowEnvironment(os.Stderr) } }