Skip to content

Instantly share code, notes, and snippets.

@peczenyj
Created February 7, 2016 18:12
Show Gist options
  • Save peczenyj/d9ddafe4a8081da3cc4d to your computer and use it in GitHub Desktop.
Save peczenyj/d9ddafe4a8081da3cc4d to your computer and use it in GitHub Desktop.
html simple creation
function html() {
local tag="$1"
local content="$2"
if [ -z "$content" ] ; then
echo "<$tag/>"
else
local attrs
if [ "$#" -gt 2 ]; then
shift 2
attrs=" $@"
fi
echo "<${tag}${attrs}>${content}</${tag}>"
fi
}
# exemplo
#
# $ html p "$(html a 'Example Link' 'href="http://www.quackit.com/html/tutorial/html_links.cfm"')"
#
# <p><a href="http://www.quackit.com/html/tutorial/html_links.cfm">Example Link</a></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment