Polish func naming in shortcode handling
authorbep <bjorn.erik.pedersen@gmail.com>
Fri, 17 Apr 2015 22:40:54 +0000 (00:40 +0200)
committerbep <bjorn.erik.pedersen@gmail.com>
Fri, 17 Apr 2015 22:40:59 +0000 (00:40 +0200)
hugolib/shortcode.go
hugolib/shortcode_test.go

index 0d396a7806ea11efc92ef32a541d3fbdf0a0e354..2429fd39de7e79f8ba5c919d81f91a8bd7bb4d4b 100644 (file)
@@ -118,9 +118,9 @@ func (sc shortcode) String() string {
        return fmt.Sprintf("%s(%q, %t){%s}", sc.name, params, sc.doMarkup, sc.inner)
 }
 
-// ShortcodesHandle does all in  one go: extract, render and replace
+// handleShortcodes does all in  one go: extract, render and replace
 // only used for testing
-func ShortcodesHandle(stringToParse string, page *Page, t tpl.Template) string {
+func handleShortcodes(stringToParse string, page *Page, t tpl.Template) string {
        tmpContent, tmpShortcodes := extractAndRenderShortcodes(stringToParse, page, t)
 
        if len(tmpShortcodes) > 0 {
@@ -171,7 +171,7 @@ const innerCleanupExpand = "$1"
 
 func renderShortcode(sc shortcode, p *Page, t tpl.Template) string {
        var data = &ShortcodeWithPage{Params: sc.params, Page: p}
-       tmpl := GetTemplate(sc.name, t)
+       tmpl := getShortcodeTemplate(sc.name, t)
 
        if tmpl == nil {
                jww.ERROR.Printf("Unable to locate template for shortcode '%s' in page %s", sc.name, p.BaseFileName())
@@ -229,7 +229,7 @@ func renderShortcode(sc shortcode, p *Page, t tpl.Template) string {
 
        }
 
-       return ShortcodeRender(tmpl, data)
+       return renderShortcodeWithPage(tmpl, data)
 }
 
 func extractAndRenderShortcodes(stringToParse string, p *Page, t tpl.Template) (string, map[string]string) {
@@ -320,7 +320,7 @@ Loop:
                        sc.inner = append(sc.inner, currItem.val)
                case tScName:
                        sc.name = currItem.val
-                       tmpl := GetTemplate(sc.name, t)
+                       tmpl := getShortcodeTemplate(sc.name, t)
 
                        if tmpl == nil {
                                return sc, fmt.Errorf("Unable to locate template for shortcode '%s' in page %s", sc.name, p.BaseFileName())
@@ -481,7 +481,7 @@ func replaceShortcodeTokens(source []byte, prefix string, wrapped bool, replacem
        return b, err
 }
 
-func GetTemplate(name string, t tpl.Template) *template.Template {
+func getShortcodeTemplate(name string, t tpl.Template) *template.Template {
        if x := t.Lookup("shortcodes/" + name + ".html"); x != nil {
                return x
        }
@@ -491,7 +491,7 @@ func GetTemplate(name string, t tpl.Template) *template.Template {
        return t.Lookup("_internal/shortcodes/" + name + ".html")
 }
 
-func ShortcodeRender(tmpl *template.Template, data *ShortcodeWithPage) string {
+func renderShortcodeWithPage(tmpl *template.Template, data *ShortcodeWithPage) string {
        buffer := bp.GetBuffer()
        defer bp.PutBuffer(buffer)
 
index ad1bd3ac850e92ef69d4bd5ff3c4283dcfecd1d9..231758da56bb3d1f335f6fa8aa75664ed6a678b6 100644 (file)
@@ -20,7 +20,7 @@ func pageFromString(in, filename string) (*Page, error) {
 func CheckShortCodeMatch(t *testing.T, input, expected string, template tpl.Template) {
 
        p, _ := pageFromString(SIMPLE_PAGE, "simple.md")
-       output := ShortcodesHandle(input, p, template)
+       output := handleShortcodes(input, p, template)
 
        if output != expected {
                t.Fatalf("Shortcode render didn't match. Expected: %q, Got: %q", expected, output)