Ejemplo n.º 1
0
// New builder with option
func New(opt *BuildOption) *Builder {
	if !com.IsDir(opt.SrcDir) {
		return &Builder{Error: ErrSrcDirMissing}
	}
	if !com.IsDir(opt.TplDir) {
		return &Builder{Error: ErrTplDirMissing}
	}
	builder := &Builder{
		parsers: []parser.Parser{
			parser.NewCommonParser(),
			parser.NewMdParser(),
		},
		Version: builderVersion{
			Num:  opt.Version,
			Date: opt.VerDate,
		},
		opt: opt,
	}
	builder.render = render.New(builder.opt.TplDir)
	builder.tasks = []*BuildTask{
		{"Data", builder.ReadData, nil},
		{"Compile", builder.Compile, nil},
		{"Feed", builder.WriteFeed, nil},
		{"Copy", builder.CopyAssets, nil},
	}
	log15.Debug("Build.Source." + opt.SrcDir)
	log15.Debug("Build.Template." + opt.TplDir)
	log15.Debug("Build.Theme." + opt.Theme)
	return builder
}
Ejemplo n.º 2
0
func TestRender(t *testing.T) {
	r := render.New("../../template")
	for name, fn := range funcMap {
		r.SetFunc(name, fn)
	}
	Convey("render load theme", t, func() {
		theme, err := r.Load("default")
		So(err, ShouldBeNil)
		So(theme, ShouldHaveSameTypeAs, new(render.Theme))

		_, err = r.Load("xxxxxx")
		So(err, ShouldEqual, render.ErrRenderDirMissing)
	})
}