Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

eleventy filter newlines

// 11ty => Filter out Newline characters in a template:
eleventyConfig.addFilter('nl2br', function(str) {
	return str.replace(/
|
|
/g, '<br />')
});

// USAGE IN A TEMPLATE: {{ some_data | nl2br }}
 
PREVIOUS NEXT
Tagged: #eleventy #filter #newlines
ADD COMMENT
Topic
Name
9+1 =