mirror of
https://git.mills.io/prologic/zs
synced 2024-11-22 05:16:11 +03:00
Add support for configuring opening and closing delimiters for plugins
This commit is contained in:
parent
f12b2286d9
commit
b23a2eb29e
14
main.go
14
main.go
@ -447,8 +447,8 @@ func getVars(path string, globals Vars) (Vars, string, error) {
|
||||
|
||||
// Render expanding zs plugins and variables
|
||||
func render(s string, vars Vars) (string, error) {
|
||||
openingDelimiter := "{{"
|
||||
closingDelimiter := "}}"
|
||||
openingDelimiter := viper.GetString("opening-delim")
|
||||
closingDelimiter := viper.GetString("closing-delim")
|
||||
|
||||
out := &bytes.Buffer{}
|
||||
for {
|
||||
@ -720,7 +720,7 @@ func init() {
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
RootCmd.PersistentFlags().BoolP("debug", "D", false, "enable debug logging $($ZS_DEBUG)")
|
||||
RootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "config file (default: .zs/config.yml)")
|
||||
RootCmd.PersistentFlags().StringVarP(&configFile, "config", "C", "", "config file (default: .zs/config.yml)")
|
||||
|
||||
RootCmd.PersistentFlags().StringSliceP("extensions", "e", MapKeys(Extensions), "override and enable specific extensions")
|
||||
RootCmd.PersistentFlags().BoolP("production", "p", false, "enable production mode ($ZS_PRODUCTION)")
|
||||
@ -729,6 +729,9 @@ func init() {
|
||||
RootCmd.PersistentFlags().StringP("keywords", "k", "", "site keywords ($ZS_KEYWORDS)")
|
||||
RootCmd.PersistentFlags().StringSliceP("vars", "v", nil, "additional variables")
|
||||
|
||||
RootCmd.PersistentFlags().StringP("opening-delim", "o", "{{", "opening delimiter for plugins")
|
||||
RootCmd.PersistentFlags().StringP("closing-delim", "c", "{{", "closing delimiter for plugins")
|
||||
|
||||
viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
|
||||
viper.SetDefault("debug", false)
|
||||
|
||||
@ -750,6 +753,11 @@ func init() {
|
||||
viper.BindPFlag("vars", RootCmd.PersistentFlags().Lookup("vars"))
|
||||
viper.SetDefault("vars", "")
|
||||
|
||||
viper.BindPFlag("opening-delim", RootCmd.PersistentFlags().Lookup("opening-delim"))
|
||||
viper.SetDefault("opening-delim", "{{")
|
||||
viper.BindPFlag("closing-delim", RootCmd.PersistentFlags().Lookup("closing-delim"))
|
||||
viper.SetDefault("closing-delim", "}}")
|
||||
|
||||
ServeCmd.Flags().StringP("bind", "b", ":8000", "set the [<address>]:<port> to listen on")
|
||||
ServeCmd.Flags().StringP("root", "r", PUBDIR, "set the root directory to serve")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user