Open calvinjuarez opened 10 years ago
Even just some way to make it so if a variable isn't defined, it just replaces the Kit comment with an empty string.
For example:
<!DOCTYPE html>
<html>
<head>...</head>
<body>
<nav>
<!-- @page = class="active" -->
<!-- @import nav.kit -->
</nav>
...
</body>
</html>
<ul>
<li <!-- &@home -->>
<a href="/">Home</a>
</li>
<li <!-- &@page -->>
<a href="/page.html">Page</a>
</li>
<li <!-- &@other -->>
<a href="/other.html">Other</a>
</li>
</ul>
(The &
here just indicates, "If this variable isn't set, don't error, just skip it.")
<!DOCTYPE html>
<html>
<head>...</head>
<body>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li class="active">
<a href="/page.html">Page</a>
</li>
<li>
<a href="/other.html">Other</a>
</li>
</ul>
</nav>
...
</body>
</html>
FYI, here's my workaround. In _nav.kit
:
<a class="btn <!--$incidentsActive-->" href="incidents.html">Incidents</a>
<a class="btn <!--$assetsActive-->" href="assets.html" >Assets</a>
<a class="btn <!--$reportsActive-->" href="reports.html" >Reports</a>
<a class="btn <!--$serviceActive-->" href="service.html" >Service</a>
<a class="btn <!--$intelActive-->" href="intel.html" >Intelligence</a>
<a class="btn <!--$adminActive-->" href="admin.html" >Administration</a>
And then, e.g., in admin.kit
:
<!-- $incidentsActive: inactive -->
<!-- $assetsActive: inactive -->
<!-- $reportsActive: inactive -->
<!-- $serviceActive: inactive -->
<!-- $intelActive: inactive -->
<!-- $adminActive: active -->
<!-- @import "nav.kit" -->
Hey Bryan, is this feature still on the radar? This would be extremely useful.
The answer given by @bdkjones on issue #6:
Yep. This is on deck for implementation.
For folks checking the status of this issue, here's a bit of a workaround that gets you conditional functionality.
<!--
; to show the content, set the value of the variable to nil
.As an example, here's what goes in the parent file:
<!-- $hideBlockOne: <!-- -->
<!-- $hideBlockTwo: nil -->
<!-- @import "_child.kit" -->
And here's the child file:
<!--$hideBlockOne-->
<div id="block-one">...</div>
<!-- end of hideBlockOne -->
<!--$hideBlockOne-->
<div id="block-two">...</div>
<!-- end of hideBlockTwo -->
The resulting compiled file will have block one commented out and block two included:
<!--
<div id="block-one">...</div>
<!-- end of hideBlockOne -->
<div id="block-two">...</div>
<!-- end of hideBlockTwo -->
Maybe it's not the most aesthetically pleasing approach, but it does get the job done.
And thanks @bdkjones for CodeKit!
Ha, that's ridiculously clever. Well done.
Sent from my iPhone
On Dec 3, 2015, at 14:16, Stephen A Thomas notifications@github.com wrote:
For folks checking the status of this issue, here's a bit of a workaround that gets you conditional functionality.
In the main file define variables to hide (or not) conditional content. To hide content, set the value of the variable to the opening HTML comment <!--; to show the content, set the value of the variable to nil.
In the included file, prefix the conditional content with the variable. After the end of the conditional content, add any HTML content.
As an example, here's what goes in the parent file:
And here's the child file:
<div id="block-one">...</div>
<div id="block-two">...</div>
The resulting compiled file will have block one commented out and block two included:
<div id="block-two">...</div>
Maybe it's not the most aesthetically pleasing approach, but it does get the job done.
And thanks @bdkjones for CodeKit!
— Reply to this email directly or view it on GitHub.
For example:
page.kit
nav.kit
page.html