Git Product home page Git Product logo

gulp-sceg's Introduction

gulp-sceg

NPM version

Styled content elements guide. sceg plugin for gulp.

Sample

Element Guide (bootstrap sample)

Uasge

$ npm install -D gulp gulp-sceg
var gulp = require('gulp');
var sceg = require('gulp-sceg');

gulp.task('guide', function() {
  return gulp.src('./path/to/src/elements/*') // Content element files (require)
    .pipe(sceg({
      layout: './path/to/src/layout.pug', // Layout template (optional)
      filename: 'guide.html', // Output guide page file name (optional)
      type: 'html', // Output file format (optional 'html' or 'json')
      pugOption, // pug options @see https://pugjs.org/api/reference.html#options
      data: { /* ... */ } // Custom data that is usable variables on layout template (optional)
    }))
    .pipe(gulp.dest('./path/to/dest/')); // Output guide page directory
});

Content element files

for example.

path/
└to/
  └src/
    └elements/
      ├00_h1.pug
      ├01_h2.pug
      ├02_h3.pug
      ├03_h4.pug
      ├04_h5.pug
      ├05_h6.pug
      ├10_ul-li.html
      ├11_ol-li.html
      ├12_dl-dd-dd.html
      ├20_table.pug
      ├21_table-caption.pug
      ├22_table-thead.pug
      └23_table-tfoot.pug

Format

html
<!--
  # Title (require)
  @Category (optional)
  Markdown comments (optional)
-->
<element class="classes" attr="val">Lorem ipsum dolor sit amet...</element>
pug (jade)
//- # Title (require)
//- @Category (optional)
//- Markdown comments (optional)
element.classes(attr="val") Lorem ipsum dolor sit amet...

Layout template

Binding data

{
  "categories": [
    {
      "name": "${category-name}",
      "id": "${category-id}"
    },
    ...
  ],
  "contents": {
    "${category-name}": {
      "category": {
        "name": "${category-name}",
        "id": "${category-id}"
      }
      "el": [
        {
          "title": "${title}",
          "html": "${element-html-string}",
          "comment": "${comment-html-string}"
        },
        ...
      ]
    },
    "${category-name}": {
      ...
    },
  }
}

Format

handlebars

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism-okaidia.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/components/prism-markup.min.js"></script>
{{#each contents}}
<section>
  <h1><a id="{{category.id}}">{{category.name}}</a></h1>
  {{#each el}}
  <section>
    <h2>{{title}}</h2>
    <h5>Preview</h5>
    {{{html}}}
    <h5>Code</h5>
    <pre class="language-markup"><code class="language-markup">{{html}}</code></pre>
    <small>
      {{{comment}}}
    </small>
  </section>
  {{/each}}
</section>
{{/each}}

pug (jade)

link(rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism.min.css')
link(rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism-okaidia.min.css')
script(src='https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/prism.min.js')
script(src='https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/components/prism-markup.min.js')
each content, category in contents
  section
    h1
      a(id=category.id)= category
    each el in content.el
      section
        h2= el.title
        h5 Preview
        !{el.html}
        h5 Code
        pre.language-markup
          code.language-markup el.html
        small !{el.comment}

©YusukeHirao(@cloud10designs), MIT license.

gulp-sceg's People

Contributors

yusukehirao avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.