hugolib: Prevent decoding pageParam in common cases - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit e98f885b8af27f5473a89d31d0b1f02e61e8a5ec
 (DIR) parent 6498d73c08438c55d45900e64c2c04a375f747c2
 (HTM) Author: Albert Nigmatzianov <albertnigma@gmail.com>
       Date:   Thu,  6 Apr 2017 22:29:37 +0200
       
       hugolib: Prevent decoding pageParam in common cases
       
       Diffstat:
         M hugolib/page.go                     |      13 +++++++++----
       
       1 file changed, 9 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/hugolib/page.go b/hugolib/page.go
       @@ -606,15 +606,20 @@ func (p *Page) renderContent(content []byte) []byte {
        }
        
        func (p *Page) getRenderingConfig() *helpers.Blackfriday {
       -
                p.renderingConfigInit.Do(func() {
       -                pageParam := cast.ToStringMap(p.GetParam("blackfriday"))
       +                p.renderingConfig = p.s.ContentSpec.NewBlackfriday()
       +
                        if p.Language() == nil {
                                panic(fmt.Sprintf("nil language for %s with source lang %s", p.BaseFileName(), p.lang))
                        }
       -                p.renderingConfig = p.s.ContentSpec.NewBlackfriday()
        
       -                if err := mapstructure.Decode(pageParam, p.renderingConfig); err != nil {
       +                bfParam := p.GetParam("blackfriday")
       +                if bfParam == nil {
       +                        return
       +                }
       +
       +                pageParam := cast.ToStringMap(bfParam)
       +                if err := mapstructure.Decode(pageParam, &p.renderingConfig); err != nil {
                                p.s.Log.FATAL.Printf("Failed to get rendering config for %s:\n%s", p.BaseFileName(), err.Error())
                        }