Beispiel #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{
		&BuildTask{"Data", builder.ReadData, nil},
		&BuildTask{"Copy", builder.CopyAssets, nil},
		&BuildTask{"Compile", builder.Compile, nil},
		&BuildTask{"Feed", builder.WriteFeed, nil},
	}
	log15.Debug("Build.Source." + opt.SrcDir)
	log15.Debug("Build.Template." + opt.TplDir)
	log15.Debug("Build.Theme." + opt.Theme)
	return builder
}
Beispiel #2
0
func TestRender(t *testing.T) {
	r := render.New("../template")
	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)
	})
}