bdkjones / Kit

The Kit Compiler, as implemented in CodeKit
77 stars 6 forks source link

feature request: yielding #5

Open szexigexi opened 10 years ago

szexigexi commented 10 years ago

it would be nice to support yielding:

basic example

layout.kit

<!doctype html>
<html>
<head>
  <title>yield ftw</title>
</head>
<body>
  <!-- @yield -->
</body>
</html>

content.kit

<!-- @layout layout -->
<p>content row 1</p>
<p>content row 2</p>
<p>content row 3</p>

result

<!doctype html>
<html>
<head>
  <title>yield ftw</title>
</head>
<body>
<p>content row 1</p>
<p>content row 2</p>
<p>content row 3</p>
</body>
</html>

a more flexible example

layout_extended.kit

<!doctype html>
<html>
<head>
  <title>yield ftw</title>
</head>
<body>
  <header>
    <!-- @yield header -->
  </header>
  <div class="content">
    <!-- @yield main -->
  </div>
</body>
</html>

content_extended.kit

<!-- @layout layout_extended -->

<!-- @content header -->
<h1>title</h1>
<p>subtitle</p>

<!-- @content main -->
<!-- @include content -->

(optionally we can close content sections with an )

result

<!doctype html>
<html>
<head>
  <title>yield ftw</title>
</head>
<body>
  <header>
<h1>title</h1>
<p>subtitle</p>
  </header>
  <div class="content">
<p>content row 1</p>
<p>content row 2</p>
<p>content row 3</p>
  </div>
</body>
</html>

or with resolved #3

<!doctype html>
<html>
<head>
  <title>yield ftw</title>
</head>
<body>
  <header>
    <h1>title</h1>
    <p>subtitle</p>
  </header>
  <div class="content">
    <p>content row 1</p>
    <p>content row 2</p>
    <p>content row 3</p>
  </div>
</body>
</html>
JayHoltslander commented 9 years ago

+1

NazarkinRoman commented 9 years ago

good idea. +1

jaimeeee commented 8 years ago

+1 came here looking for this, I'm glad someone already addressed.