Exemple #1
0
func main() {
	debug := false
	flag.Usage = Usage

	flag.Parse()
	options := gorazor.Option{}
	if debug {
		options["Debug"] = true
	}

	if flag.NArg() == 2 {
		arg1, arg2 := flag.Arg(0), flag.Arg(1)
		stat, err := os.Stat(arg1)
		if err != nil {
			fmt.Println(err)
			os.Exit(2)
		}
		if stat.IsDir() {
			fmt.Printf("Processing dir: %s %s\n", arg1, arg2)
			err := gorazor.GenFolder(arg1, arg2, options)
			if err != nil {
				fmt.Println(err)
			}
		} else if stat.Mode().IsRegular() {
			fmt.Printf("Processing file: %s %s\n", arg1, arg2)
			gorazor.GenFile(arg1, arg2, options)
		} else {
			flag.Usage()
		}
	} else {
		flag.Usage()
	}

}
Exemple #2
0
func MustBuildTplWithPath(path string) {
	kmgCache.MustMd5FileChangeCache("tpl_"+kmgBase64.Base64EncodeStringToString(path), []string{path}, func() {
		fmt.Println("build tpl at " + path)
		err := gorazor.GenFolder(path, path, gorazor.Option{"NameNotChange": true})
		if err != nil {
			panic(err)
		}
	})
}
Exemple #3
0
func main() {
	flag.Usage = Usage
	isDebug := flag.Bool("debug", false, "use debug mode")
	isWatch := flag.Bool("watch", false, "use watch mode")
	nameNotChange := flag.Bool("nameNotChange", false, "do not change name of the template")

	flag.Parse()

	options := gorazor.Option{}

	if *isDebug {
		options["Debug"] = *isDebug
	}
	if *isWatch {
		options["Watch"] = *isWatch
	}
	if *nameNotChange {
		options["NameNotChange"] = *nameNotChange
	}

	if len(flag.Args()) != 2 {
		flag.Usage()
	}

	input, output := flag.Arg(0), flag.Arg(1)
	stat, err := os.Stat(input)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	if stat.IsDir() {
		fmt.Printf("Gorazor processing dir: %s -> %s\n", input, output)
		err := gorazor.GenFolder(input, output, options)
		if err != nil {
			fmt.Println(err)
		}
	} else if stat.Mode().IsRegular() {
		fmt.Printf("Gorazor processing file: %s -> %s\n", input, output)
		gorazor.GenFile(input, output, options)
	}
}