I am using gulp-file-include to build my html pages using some partials & templates. By using context variables, I can customize each meta headers. However, don't know how I could include a line only if a context variable exists, as the "@@else" statement doesn't seem to exist.
My parent HTML looks like:
@@include ('_header.html', {
"title":"my page",
"description": "description",
"canonical":"http://ift.tt/1McPhM8" })
<body>
A wonderful Page
@@include ('_footer.html")
</body></html>
I was thinking to use a _header.html close to something like that :
<html>
<head>
<title>@@title</title>
<meta name="description" content="@@description">
@@if (canonical) { <link rel="canonical" href="@@canonical" /> }
</head>
If the "canonical" variable is not set in the the parent HTML, it throws an error (canonical is not defined).
I guess I could include the full tag in a variable and forget about the @@if, but that would not be as clean as expected !
Any ideas ? Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire