open-index/open-npm huggingface dataset:
npm package: @impjs/babel-plugin-transform-jsx-to-template-literals
Description: Template for NodeJS projects
Author: Romaric Pascal
Latest version: 0.0.1-alpha.1

babel-plugin-transform-jsx-to-template-literals
===

A Babel transform to transform JSX into template literals.

```js
<h1 class={classnames}>{title}</h1>

// Becomes

`<h1 class=${classnames}>${title}</h1>`
```

Children are also handled too:

```js
<article>
  <h2>{title}</h2>
  <div class="content">{content}</div>
</article>

// Becomes

`<article class="article">
  <h2>${title}</h2>
  <div class="article__content">${content}</div>
</article>`
```

If there is a spread, it'll be handled the following way:


```js
<a href={href} {...props}>{content}</a>

// Becomes
`<a ${_attributes({href},props)}>${content}</a>`

// `_attributes` will be imported from a configurable package
// by default, just merge the two hashes
```

Imported components are run

```js
const product = require('product');

<product {...productData}></product>

// Becomes

const product = require('product');

`${product(productData)}`
```

Children are passed to them as a `children` property.

```js
const card = require('card');

<card title={title}>
  <div class="content"></div>
  {() => {/* Some code */}}
</card>

// Becomes
`${card({
    title,
    children: [
      `<div class="content"></div>`,
      () => {/* Some code */}
    ]
)}`
```
npm package: @impjs/babel-plugin-transform-tag-template-literals
Description: Template for NodeJS projects
Author: Romaric Pascal
Latest version: 0.0.1-alpha.1

babel-plugin-transform-tag-template-literals
---

A Babel transform that tags each non-tagged template literal with a chosen identifier.

```js
`a template ${literal}`

// Will become

html`a template ${literal}`

```

Usage
---

Usage

Install the plugin with your favourite package manager. For example, with NPM:

```sh
npm install --save-dev babel-plugin-transform-last-statement
```

Then in your Babel configuration, add it to the list of plugins:

```js
{
  plugins:['transform-tag-template-literals']
}
```

Options
---

- `tagName`: The identifier to use for the tag function. If empty, the plugin won't try to tag anything

Possible future work
---

- [ ] Allow to set which tagName to use through a comment, like `// tag-template-literals: tagName`. Some thoughts will be needed for the scoping. Apply to next block (`function`,`if`...) or maybe use a `// end-tag-template-literals`?
npm package: @impjs/babel-plugin-transform-undeclared-variables
Description: Transforms undeclared variables into imports or getter calls
Author: Romaric Pascal
Latest version: 0.0.1-alpha.1

babel-plugin-transform-undeclared-variables
===

A Babel transform to transform undeclared variables into a getter call or an import.

Note: undeclared variables on the left hand side of assignments are ignored.

```js
function template(data) {
  return html`A template ${literal}`;
}

// Would become
import html from './templateTag';

function template(data) {
  return html`A template ${data.literal}`;
}

```

Usage
---

Install the plugin with your favourite package manager. For example, with NPM:

```sh
npm install --save-dev babel-plugin-transform-last-statement
```

Then in your [Babel configuration][babel-configuration], add it to the list of plugins:

```js
{
  plugins:['transform-undeclared-variables']
}
```

Options
---

By default, the transform will turn all undeclared variables into a getter call on the `data` object. You can configure:

- `default`: the default behaviour,
- `variables`: the behaviour for specific variables

```js
default: getter('<otherObjectName'),
variables: {
  '<undeclaredIdentifierName>': getter('<objectName>'),
  '<otherUndeclaredIdentifierName>': addImport('<package>', {name: '<exportName>'}).
  '<yetAnotherUndeclaredIdentifierName>': function(path) { 
    // Do whatever you need to transform that specific identifier
  }
}
```

Possible future work
---
- [ ] Allow configuration through non-JS babel configuration files, by allowing arrays instead of function calls
  ```json
  {
    "default": ["getter","otherObject"],
    "variables": {
      "undefinedVariable": ["addImport","package", {name: "exportName"}]
    }
  }
  ```
- [ ] Handle left side of assignments by creating a variable declaration automatically (type of declaration configurable).

[babel-configuration]: https://babeljs.io/docs/en/config-files
npm package: @impjs/babel-preset-impjs
Description: Template for NodeJS projects
Author: Romaric Pascal
Latest version: 0.0.1-alpha.2

almost-js
===

> **WORK IN PROGRESS**

A templating engine using as much as possible of what the JavaScript language gives (especially template literals).

Templates are plain JavaScript files whose last non-function statements are returned and formatted into a String.

This allows various things:
```js
// Explicitely require the necessary helpers
// instead of losing which are used in a global 
// list of helpers. It also avoid naming collisions
// between helpers
const {escape} = require('./html')

// Some pre-processing of the template data
// right next to the code rendering it
// (Admitedly the following chunk of code could
// well be in its own helper)
const htmlAttributes = Object.entries(attributes).map(([name,value] => `name=${escape(value)}`)).join(' ');

// Use regular template literals to generate the resulting HTML
`<article ${htmlAttributes}>
  `<h1>${post.title}</h1>`
  ${() => {
    // Function expressions are automatically evaluated
    // Allowing to use plain Javascript `if`
    if (post.excerpt) {
      // Their last statement is automatically returned
      // to not cluter the template with `return`
      post.excerpt
    }
  }}
  ${tagList(post)}
</article>`

// Chunkier part of the template can be extracted
// in their own function
function tagList(post) {
  `<ul>
    ${() => {
      // Just like `if`, `for` loops' final statements get returned
      for(var i = 0; i < post.tags.length; i++) {
        const tag = post.tags[i];
        `<li><a href="/tags/${tag.slug}">${tag.name}</a></li>`
      }
    }}
  </ul>`
}
```

TODO
---

- [x] Basic proof of concept
- [x] Configuration options
  - [x] Override formatting of template expressions
  - [x] Override function used for tagging literals
- [x] General API
  - [x] `compile`
  - [x] `compileFile`
  - [x] `render`
  - [x] `renderFile`
- [x] Caching
- [x] Require other templates
- [x] Globals (`console`,...)
- [x] Express template engine
- [ ] Webpack loader
- [ ] transform for NodeJS `require`
- [ ] JSX support (compile it to template literals, maybe using this [jsx-to-htm transform](https://github.com/developit/htm/tree/master/packages/babel-plugin-transform-jsx-to-htm))
- [ ] Custom parser to parse statements inside template literal expressions as IIFEs or arrow functions, saving a little more boilerplate, allowing:
  ```js
  `<ul>
    ${for(var i = 0; i < 5; i++) {
      `Value: ${i}`
    }}
  </ul>`
  ```
npm package: @impjs/babel-preset-implicitjs
Description: Template for NodeJS projects
Author: Romaric Pascal
Latest version: 0.0.1-alpha.1

almost-js
===

> **WORK IN PROGRESS**

A templating engine using as much as possible of what the JavaScript language gives (especially template literals).

Templates are plain JavaScript files whose last non-function statements are returned and formatted into a String.

This allows various things:
```js
// Explicitely require the necessary helpers
// instead of losing which are used in a global 
// list of helpers. It also avoid naming collisions
// between helpers
const {escape} = require('./html')

// Some pre-processing of the template data
// right next to the code rendering it
// (Admitedly the following chunk of code could
// well be in its own helper)
const htmlAttributes = Object.entries(attributes).map(([name,value] => `name=${escape(value)}`)).join(' ');

// Use regular template literals to generate the resulting HTML
`<article ${htmlAttributes}>
  `<h1>${post.title}</h1>`
  ${() => {
    // Function expressions are automatically evaluated
    // Allowing to use plain Javascript `if`
    if (post.excerpt) {
      // Their last statement is automatically returned
      // to not cluter the template with `return`
      post.excerpt
    }
  }}
  ${tagList(post)}
</article>`

// Chunkier part of the template can be extracted
// in their own function
function tagList(post) {
  `<ul>
    ${() => {
      // Just like `if`, `for` loops' final statements get returned
      for(var i = 0; i < post.tags.length; i++) {
        const tag = post.tags[i];
        `<li><a href="/tags/${tag.slug}">${tag.name}</a></li>`
      }
    }}
  </ul>`
}
```

TODO
---

- [x] Basic proof of concept
- [x] Configuration options
  - [x] Override formatting of template expressions
  - [x] Override function used for tagging literals
- [x] General API
  - [x] `compile`
  - [x] `compileFile`
  - [x] `render`
  - [x] `renderFile`
- [x] Caching
- [x] Require other templates
- [x] Globals (`console`,...)
- [x] Express template engine
- [ ] Webpack loader
- [ ] transform for NodeJS `require`
- [ ] JSX support (compile it to template literals, maybe using this [jsx-to-htm transform](https://github.com/developit/htm/tree/master/packages/babel-plugin-transform-jsx-to-htm))
- [ ] Custom parser to parse statements inside template literal expressions as IIFEs or arrow functions, saving a little more boilerplate, allowing:
  ```js
  `<ul>
    ${for(var i = 0; i < 5; i++) {
      `Value: ${i}`
    }}
  </ul>`
  ```
npm package: @impjs/impjs
Description: Template for NodeJS projects
Author: Romaric Pascal
Latest version: 0.0.1-alpha.2

almost-js
===

> **WORK IN PROGRESS**

A templating engine using as much as possible of what the JavaScript language gives (especially template literals).

Templates are plain JavaScript files whose last non-function statements are returned and formatted into a String.

This allows various things:
```js
// Explicitely require the necessary helpers
// instead of losing which are used in a global 
// list of helpers. It also avoid naming collisions
// between helpers
const {escape} = require('./html')

// Some pre-processing of the template data
// right next to the code rendering it
// (Admitedly the following chunk of code could
// well be in its own helper)
const htmlAttributes = Object.entries(attributes).map(([name,value] => `name=${escape(value)}`)).join(' ');

// Use regular template literals to generate the resulting HTML
`<article ${htmlAttributes}>
  <h1>${post.title}</h1>
  ${() => {
    // Function expressions are automatically evaluated
    // Allowing to use plain Javascript `if`
    if (post.excerpt) {
      // Their last statement is automatically returned
      // to not cluter the template with `return`
      post.excerpt
    }
  }}
  ${tagList(post)}
</article>`

// Chunkier part of the template can be extracted
// in their own function
function tagList(post) {
  `<ul>
    ${() => {
      // Just like `if`, `for` loops' final statements get returned
      for(var i = 0; i < post.tags.length; i++) {
        const tag = post.tags[i];
        `<li><a href="/tags/${tag.slug}">${tag.name}</a></li>`
      }
    }}
  </ul>`
}
```

TODO
---

- [ ] Add option for customizing Babel configuration
- [ ] Maybe rename the express template engine to `expressTemplateEngine` rather than the more obscure `__express`
npm package: @impjs/omniformat
Description: Formats strings from any kind of objects
Author: Romaric Pascal
Latest version: 0.0.1-alpha.2

Omniformat
===

Formats any value into a String, invoking functions, handling promises results, and mapping iterators' (`Array`, `Map`, `Set`...) values, then joining them. Recursively formats the returned values from functions, promises and iterators.

Installation and usage
---

Install the library via your favourite package manager:

```shell
npm install omniformat
```

Then import or require it in your project and profit

```js
const format = require('@impjs/omniformat');

format('Look, a plane!') // Strings are passed as is 'Look, a plane!'
format({content: 'Look, a plane!'}) // Objects are JSON.stringified '{"content": "Look, a plane!"}
format(() => 'Look, a plane!') // Functions are evaluated `'Look, a plane!'`
format(Promise.resolve(() => 'Look, a plane!')) // Returns a Promise for 'Look, a plane!'
format(['Look,',() => 'a','plane'], {iteratorJoinString: ' '}) // Iterators elements are each formated and their value `String.prototype.join`ed
```

Formatting description
---

### Numbers and Strings

These are just passed to the function itself.

### Objects

`Object`s will be `JSON.stringify`ed.

> **WARNING**: `JSON.stringify` breaks when objects have circular references. Please take care of this before passing your object to the formatter.

> **FUTURE**: Possibly allow a `objectFormater` option that would customize how Objects are formatted. For example, mapping their values, or traversing to format each key deeply. Or call a `format` method maybe.

### Functions

`Function`s will be invoked and their results formatted again.

### Promises

`Promise`s will be awaited and their results formatted again.

### Arrays & iterators

`Array`s and objects with an iterator (`Sets`,`Maps` and any objects with a `[Symbol.iterator]`, except Strings) will have each of their item formatted, the possible resulting promises awaited, and the results then joined with an empty string.

The string used for joining can be configured with the `iteratorJoinString`.

Extending the function
---

You can implement extra formatting, process the formatted values or override the formatting for specific kinds of expressions by wrapping the `format` function in your own. Don't forget to pass your function as the `formatResults` option so that results of functions, promises and iterators are formatted by your function and not the original implementation.

For example:

```js
// Let's create our own formatter that uppercases strings
function formatWithUppercasedStrings(expression) {
  if (typeof expression === 'string') {
    return expression.toUpperCase();
  }
  // IMPORTANT: Pass the function as the `format` option
  // without it, formating of results will use the original
  // implementation
  return format(expression, {format: formatWithUppercasedStrings});
}
```