debug.go (1417B)
1 // Copyright 2020 The Hugo Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 // Package debug provides template functions to help debugging templates. 15 package debug 16 17 import ( 18 "github.com/sanity-io/litter" 19 20 "github.com/gohugoio/hugo/deps" 21 ) 22 23 // New returns a new instance of the debug-namespaced template functions. 24 func New(d *deps.Deps) *Namespace { 25 return &Namespace{} 26 } 27 28 // Namespace provides template functions for the "debug" namespace. 29 type Namespace struct { 30 } 31 32 // Dump returns a object dump of val as a string. 33 // Note that not every value passed to Dump will print so nicely, but 34 // we'll improve on that. We recommend using the "go" Chroma lexer to format the output 35 // nicely. 36 // Also note that the output from Dump may change from Hugo version to the next, 37 // so don't depend on a specific output. 38 func (ns *Namespace) Dump(val any) string { 39 return litter.Sdump(val) 40 }