Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tokugawatakeshi/handlebarsbypug

Pug mixins for the outputting of the Handlebars code instead of plain HTML.
https://github.com/tokugawatakeshi/handlebarsbypug

Last synced: about 1 month ago
JSON representation

Pug mixins for the outputting of the Handlebars code instead of plain HTML.

Awesome Lists containing this project

README

        

# Handlebars by Pug

[Pug mixins](https://pugjs.org/language/mixins.html) for the outputting of the [Handlebars](https://handlebarsjs.com/guide/) code instead of plain HTML.

## Installation

```bash
npm i handlebars-by-pug -D -E
```

## Functionality

### Will work with plain Handlebars

#### `HandlebarsCondition`

```pug
dl

dt.MemberProfile-Profile-KeyCell Full Name
dd.MemberProfile-Profile-ValueCell {{ fullName }}

+HandlebarsCondition("phoneNumber")
dt.MemberProfile-Profile-KeyCell Phone number
dd.MemberProfile-Profile-ValueCell {{ phoneNumber }}
```

Output (manually formatted):

```handlebars



Full Name

{{ fullName }}


{{#if phoneNumber}}
Phone number

{{ phoneNumber }}

{{/if}}


```

#### `HandlebarsIteration`

```pug
+HandlebarsCondition("items")

ul

+HandlebarsIteration("items")

li {{ this }}
```

Output (manually formatted):

```handlebars
{{#if items}}


    {{#each items}}
  • {{ this }}

  • {{/each}}

{{/if}}
```

#### HandlebarsHelper

```pug
+HandlebarsHelper("unless", "license")
p WARNING: This entry does not have a license!
```

Output (manually formatted):

```handlebars
{{#unless license}}

WARNING: This entry does not have a license!


{{/unless}}
```

### Depends on `@yamato-daiwa/handlebars-extensions`

```bash
npm i @yamato-daiwa/handlebars-extensions -E
```

### `AreStringsEqual--HandlebarsHelper`

```pug
dl

dt Full Name
dd {{ fullName }}

+HandlebarsHelper("isNonEmptyObject", "socialNetworkProfilesURIs")

dt Social networks
dd

ul
+HandlebarsIteration("socialNetworkProfilesURIs")
li

+AreStringsEqual--HandlebarsHelper("@key", "facebook")
a(href=`{{ this }}`)
svg
// The SVG code of teh Facebook icon ...

+AreStringsEqual--HandlebarsHelper("@key", "instagram")
a(href=`{{ this }}`)
svg
// The SVG code of teh Instagram icon ...

+AreStringsEqual--HandlebarsHelper("@key", "twitter")
a(href=`{{ this }}`)
svg
// The SVG code of teh Twitter icon ...
```

Output (manually formatted):

```handlebars



Full Name

{{ fullName }}


{{#isNonEmptyObject socialNetworkProfilesURIs}}
Social networks




    {{#each socialNetworkProfilesURIs}}



  • {{#areStringsEqual @key "facebook"}}





    {{/areStringsEqual}}

    {{#areStringsEqual @key "instagram"}}





    {{/areStringsEqual}}

    {{#areStringsEqual @key "twitter"}}





    {{/areStringsEqual}}



  • {{/each}}




{{/isNonEmptyObject}}


```