~artemis/cap

99ddb5227c0dec7f7ae1b5948281e34a342506df — Artemis 1 year, 15 days ago 919fd21
clean: removed duplication of templates map between html and rss
1 files changed, 7 insertions(+), 10 deletions(-)

M handler.go
M handler.go => handler.go +7 -10
@@ 163,20 163,17 @@ func (f *FsBuilder) HandleFeed(feed *domain.Feed) error {

	// 1. Custom selector handling
	if feed.PageSelectionPattern != "" {
		template, err := template.New(feed.Path).Funcs(template.FuncMap{
		funcs := template.FuncMap{
			"collect": func(pages []*domain.Page) int {
				includedPages = pages
				return len(includedPages)
			},
			// must be duplicated because golang is too stupid to spread a map
			"get_root_section": GetRootSection,
			"get_subsection":   GetSubsection,
			"all_pages":        GetAllPages,
			"by_date":          ByDate,
			"by_name":          ByName,
			"published":        OnlyPublished,
			"unpublished":      OnlyUnpublished,
		}).Parse(feed.PageSelectionPattern)
		}
		for k, v := range templateFuncs {
			funcs[k] = v
		}

		template, err := template.New(feed.Path).Funcs(funcs).Parse(feed.PageSelectionPattern)
		if err != nil {
			return err
		}