1.0.0 • Published 7 years ago

one-helpers v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

One Helpers

Build Status Maintainability Coverage Status JavaScript Style Guide

Provider some helper to working with template string in ONE framework.

  Install

just declare "one-helpers" in your map.

require('one-helpers')
const rw = require('roow')

const header = rw.getComponent('src/components/header/header.html')
const center = rw.getComponent('src/components/center/center.html')
const footer = rw.getComponent('src/components/footer/footer.html')

module.exports.page = './pages/index.html'

module.exports.pageContent = `
  ${header({
    title: 'One - home page',
    color: '#cc3333'
  })}
  ${center()}
  ${footer()}
`

🛠   Functions

_if: boolean, string, string → string

  • Return a string based in condition value.
<section>
    ${_if(true, "hello")}
    ${_if(false, "world")}
</section>

👇

<section>
    Hello
</section>

_if_else: boolean, string, string → string

  • Return a string based in condition value.
<section>
    ${_if_else(false, "accepted", "rejected")}
</section>

👇

<section>
    rejected
</section>

_loop: number, string → string

Return a string concated n times.

<section>
    ${_loop(3, "<h1>hi!</h1>")}
</section>

👇

<section>
    <h1>hi!</h1>
    <h1>hi!</h1>
    <h1>hi!</h1>
</section>

👨‍💻   Development

install

$ npm install

tests

$ npm test

Licensed under the ISC License 2018 - C4co

1.0.0

7 years ago