1.13.5 • Published 2 years ago

handlebarstojsrender v1.13.5

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

NPM Downloads

HandlebarsToJSRender

  • Problem: It can be hard to create very modular components (updated ones, at least).
  • What should be: It should be quite easy to use hourglass components, but this is not the case when we are trying to create modular components.
  • What actually is: If we want to create as modular components as possible, we want to ensure that we update the UI accordingly.
  • Hypothesis: If we can do this well, then it'll be easier to create more modular components, thereby making our application more testable.
  • Plan: Create a process in which we can pull different components and then render accordingly.
  • The purpose of this class is to more easily created updated modular components - we are going to be reading from our global folder, build the components, and then render them into an index.html file accordingly

Directions

See example here - example

  1. Install the package
npm install handlebarstojsrender
  1. Instantiate it in a javascript file
const HandlebarsToJSRender = require("handlebarstojsrender")
  1. Pass in object configuration
let options = {

    folderPaths: ["./views/partials/components", "./views/partials/content", "./views/partials/layouts"],
    dictionary: {
        "WHATSHOULDBE_INPUT": "{{whatshouldbe}}",
        "PROBLEM_INPUT": "{{problem}}",
        "WHATACTUALLYIS_INPUT": "{{whatactuallyis}}",
        "HYPOTHESIS_INPUT": "{{hypothesis}}",
        "PLAN_INPUT": "{{plan}}",
    },

}
<a name="HandlebarsToJSRender"></a>

## HandlebarsToJSRender
**Kind**: global class  
**Date**: 2022-02-08  

* [HandlebarsToJSRender](#HandlebarsToJSRender)
    * [new HandlebarsToJSRender(options)](#new_HandlebarsToJSRender_new)
    * [.init()](#HandlebarsToJSRender+init) ⇒ <code>null</code>
    * [.resetFile()](#HandlebarsToJSRender+resetFile) ⇒ <code>null</code>
    * [.replaceSyntax(testOne)](#HandlebarsToJSRender+replaceSyntax) ⇒ <code>any</code>
    * [.replaceAll(string, original, itemToReplace)](#HandlebarsToJSRender+replaceAll) ⇒ <code>string</code>
    * [.replaceForBuild(string)](#HandlebarsToJSRender+replaceForBuild) ⇒ <code>string</code>
    * [.readFolder()](#HandlebarsToJSRender+readFolder)
    * [.replaceForProduction(string)](#HandlebarsToJSRender+replaceForProduction) ⇒ <code>string</code>
    * [.getBeginningTemplate()](#HandlebarsToJSRender+getBeginningTemplate) ⇒ <code>string</code>
    * [.getEndingTemplate()](#HandlebarsToJSRender+getEndingTemplate) ⇒ <code>string</code>

<a name="new_HandlebarsToJSRender_new"></a>

### new HandlebarsToJSRender(options)
let handlebarsToJSRender = new HandlebarsToJSRender({folderPaths: [""], dictionary: {STRING_TO_REPLACE_HBSSYNTAX: HBSSYNTAX}})


| Param | Type |
| --- | --- |
| options | <code>any</code> | 

<a name="HandlebarsToJSRender+init"></a>

### handlebarsToJSRender.init() ⇒ <code>null</code>
Will reset the entire file

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  
**Date**: 2022-02-08  
<a name="HandlebarsToJSRender+resetFile"></a>

### handlebarsToJSRender.resetFile() ⇒ <code>null</code>
Resets index.html file

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  
**Date**: 2022-02-08  
<a name="HandlebarsToJSRender+replaceSyntax"></a>

### handlebarsToJSRender.replaceSyntax(testOne) ⇒ <code>any</code>
Replaces all partials {{> }} with {{include templ=''}}
Replaces {{#each data}}{{/each}} with {{for data}}{{/for}}

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  
**Date**: 2022-02-08  

| Param | Type |
| --- | --- |
| testOne | <code>any</code> | 

<a name="HandlebarsToJSRender+replaceAll"></a>

### handlebarsToJSRender.replaceAll(string, original, itemToReplace) ⇒ <code>string</code>
1. While string includes second parameter
2. Replace with third parameter

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  

| Param | Type |
| --- | --- |
| string | <code>string</code> | 
| original | <code>string</code> | 
| itemToReplace | <code>string</code> | 

<a name="HandlebarsToJSRender+replaceForBuild"></a>

### handlebarsToJSRender.replaceForBuild(string) ⇒ <code>string</code>
will replace all the items that you have with regular text so we can render it via jsrender

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  
**Date**: 2022-02-08  

| Param | Type |
| --- | --- |
| string | <code>any</code> | 

<a name="HandlebarsToJSRender+readFolder"></a>

### handlebarsToJSRender.readFolder()
1. Reads through options.folderPaths, and if wrap is true, will wrap around x-jsrender tag 
2. Will also give the id as its file name

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  
**Date**: 2022-02-08  
<a name="HandlebarsToJSRender+replaceForProduction"></a>

### handlebarsToJSRender.replaceForProduction(string) ⇒ <code>string</code>
replaceForProduction(string)
1. Loops through dictionary
2. Replaces all instances of the value, if key found in string 
3. Returns string

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  
**Date**: 2022-02-08  

| Param | Type |
| --- | --- |
| string | <code>any</code> | 

<a name="HandlebarsToJSRender+getBeginningTemplate"></a>

### handlebarsToJSRender.getBeginningTemplate() ⇒ <code>string</code>
getBeginningTemplate()

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  
**Date**: 2022-02-08  
<a name="HandlebarsToJSRender+getEndingTemplate"></a>

### handlebarsToJSRender.getEndingTemplate() ⇒ <code>string</code>
getEndingTemplate()

**Kind**: instance method of [<code>HandlebarsToJSRender</code>](#HandlebarsToJSRender)  
**Date**: 2022-02-08  
1.13.1

2 years ago

1.13.5

2 years ago

1.13.4

2 years ago

1.13.0

2 years ago

1.12.0

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago