diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-05 10:20:06 +0700 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-17 17:15:26 +0100 |
commit | 93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch) | |
tree | 5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /hugolib/shortcode.go | |
parent | e34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff) |
all: Refactor to nonglobal Viper, i18n etc.
This is a final rewrite that removes all the global state in Hugo, which also enables
the use if `t.Parallel` in tests.
Updates #2701
Fixes #3016
Diffstat (limited to 'hugolib/shortcode.go')
-rw-r--r-- | hugolib/shortcode.go | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go index afee1884f..4ce6df7e9 100644 --- a/hugolib/shortcode.go +++ b/hugolib/shortcode.go @@ -149,31 +149,6 @@ func (sc shortcode) String() string { return fmt.Sprintf("%s(%q, %t){%s}", sc.name, params, sc.doMarkup, sc.inner) } -// HandleShortcodes does all in one go: extract, render and replace -// only used for testing -func HandleShortcodes(stringToParse string, page *Page) (string, error) { - tmpContent, tmpShortcodes, err := extractAndRenderShortcodes(stringToParse, page) - - if err != nil { - return "", err - } - - if len(tmpShortcodes) > 0 { - shortcodes, err := executeShortcodeFuncMap(tmpShortcodes) - if err != nil { - return "", err - } - tmpContentWithTokensReplaced, err := replaceShortcodeTokens([]byte(tmpContent), shortcodePlaceholderPrefix, shortcodes) - - if err != nil { - return "", fmt.Errorf("Failed to replace shortcode tokens in %s:\n%s", page.BaseFileName(), err.Error()) - } - return string(tmpContentWithTokensReplaced), nil - } - - return tmpContent, nil -} - var isInnerShortcodeCache = struct { sync.RWMutex m map[string]bool @@ -239,12 +214,12 @@ func renderShortcode(sc shortcode, parent *ShortcodeWithPage, p *Page) string { } if sc.doMarkup { - newInner := helpers.RenderBytes(&helpers.RenderingContext{ + newInner := p.s.ContentSpec.RenderBytes(&helpers.RenderingContext{ Content: []byte(inner), PageFmt: p.determineMarkupType(), - ConfigProvider: p.Language(), - DocumentID: p.UniqueID(), - DocumentName: p.Path(), - Config: p.getRenderingConfig()}) + Cfg: p.Language(), + DocumentID: p.UniqueID(), + DocumentName: p.Path(), + Config: p.getRenderingConfig()}) // If the type is “unknown” or “markdown”, we assume the markdown // generation has been performed. Given the input: `a line`, markdown |