Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/tokugawatakeshi/handlebarsbypug
- Owner: TokugawaTakeshi
- License: mit
- Created: 2023-09-02T03:22:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-14T00:54:14.000Z (about 1 year ago)
- Last Synced: 2024-10-14T05:21:14.591Z (about 1 month ago)
- Language: Pug
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
dldt.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 }}
- Phone number
- {{ phoneNumber }}
{{#if phoneNumber}}
{{/if}}
```
#### `HandlebarsIteration`
```pug
+HandlebarsCondition("items")
ul
+HandlebarsIteration("items")
li {{ this }}
```
Output (manually formatted):
```handlebars
{{#if items}}
- {{ this }}
{{#each items}}
{{/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 }}
- Social networks
-
-
{{#areStringsEqual @key "facebook"}}
{{/areStringsEqual}}
{{#areStringsEqual @key "instagram"}}
{{/areStringsEqual}}
{{#areStringsEqual @key "twitter"}}
{{/areStringsEqual}}
{{#each socialNetworkProfilesURIs}}
{{/each}}
-
{{#isNonEmptyObject socialNetworkProfilesURIs}}
{{/isNonEmptyObject}}
```