Move \n -> paragraphs out of fill_template
- As it should only be done for the custom format
This commit is contained in:
+8
-9
@@ -8,19 +8,17 @@ post_feed_template = File.read!("./templates/posts.xml")
|
||||
# Converting handlebars in template to values
|
||||
fill_template = fn template, pairs ->
|
||||
Regex.compile!("{{(.*)}}") |>
|
||||
Regex.replace(template, fn _, key -> if key != "content" do Map.get(pairs, String.to_atom(key)) else
|
||||
Map.get(pairs, String.to_atom(key))
|
||||
# Converting \n to paragraphs
|
||||
|> String.split("\\n")
|
||||
|> Enum.reject(fn(x) -> x == "" end)
|
||||
|> Enum.map(fn paragraph -> ("<p>" <> paragraph <> "</p>\n") end)
|
||||
|> Enum.join("")
|
||||
end
|
||||
end)
|
||||
Regex.replace(template, fn _, key -> Map.get(pairs, String.to_atom(key)) end)
|
||||
end
|
||||
|
||||
fill_template_pretemplated = fn template -> &fill_template.(template, &1) end
|
||||
|
||||
wrapInParagraphs = fn content -> content
|
||||
|> String.split("\\n")
|
||||
|> Enum.reject(fn(x) -> x == "" end)
|
||||
|> Enum.map(fn paragraph -> "<p>" <> paragraph <> "</p>" end)
|
||||
|> Enum.join("")
|
||||
end
|
||||
post_contents_custom = File.ls!("./posts_custom")
|
||||
|> Enum.reject(fn(x) -> String.starts_with?(x, ".") end)
|
||||
|> Enum.map(fn f -> File.read!("./posts_custom/" <> f) end)
|
||||
@@ -31,6 +29,7 @@ post_contents_custom = File.ls!("./posts_custom")
|
||||
Enum.map(c, fn [k, v] -> %{String.to_atom(k) => v} end)
|
||||
|> Enum.reduce(%{}, fn(x, acc) -> Map.merge(x, acc) end)
|
||||
end)
|
||||
|> Enum.map(fn m -> Map.update!(m, :content, wrapInParagraphs) end)
|
||||
|
||||
filterCutFileExtension = fn files ->
|
||||
fn ext ->
|
||||
|
||||
Reference in New Issue
Block a user