Skip to content

Commit

Permalink
Merge pull request #54 from eta-dev/build-deno
Browse files Browse the repository at this point in the history
Rebuild deno build
  • Loading branch information
shadowtime2000 authored Nov 29, 2020
2 parents f8950a7 + 145c127 commit 75944e6
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 4 deletions.
44 changes: 43 additions & 1 deletion deno_dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</p>

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[logo]: https://img.shields.io/badge/all_contributors-7-orange.svg 'Number of contributors on All-Contributors'
[logo]: https://img.shields.io/badge/all_contributors-8-orange.svg 'Number of contributors on All-Contributors'
<!-- ALL-CONTRIBUTORS-BADGE:END -->

<span align="center">
Expand Down Expand Up @@ -134,6 +134,45 @@ Simply put, Eta is super: super lightweight, super fast, super powerful, and sup

Additionally, Eta is a letter of the Greek alphabet (it stands for all sorts of cool things in various mathematical fields, including efficiency) and is three letters long (perfect for a file extension).

## Integrations

<details>
<summary>
<b>ESLint</b>
</summary>

[eslint-plugin-eta](https://github.com/eta-dev/eslint-plugin-eta) was created to provide an ESLint processor so you can lint your Eta templates.

</details>

<details>
<summary>
<b>CLI</b>
</summary>

An official Eta CLI exists called [etajs-cli](https://github.com/eta-dev/etajs-cli).

</details>

<details>
<summary>
<b>Webpack</b>
</summary>

Currently there is no official Webpack integration but [@clshortfuse](https://github.com/clshortfuse) shared the loader he uses:
```javascript
{
loader: 'html-loader',
options: {
preprocessor(content, loaderContext) {
return eta.render(content, {}, { filename: loaderContext.resourcePath });
},
},
}
```

</details>

## 📜 Docs

We know nobody reads through the long and boring documentation in the ReadMe anyway, so head over to the documentation website:
Expand Down Expand Up @@ -216,6 +255,9 @@ Made with ❤ by [@nebrelbug](https://github.com/eta-dev) and all these wonderfu
<td align="center"><a href="https://shadowtime2000.github.io"><img src="https://avatars1.githubusercontent.com/u/66655515?v=4" width="100px;" alt=""/><br /><sub><b>shadowtime2000</b></sub></a><br /><a href="https://github.com/eta-dev/eta/commits?author=shadowtime2000" title="Code">💻</a> <a href="#ideas-shadowtime2000" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://hamidihamza.com"><img src="https://avatars0.githubusercontent.com/u/22576950?v=4" width="100px;" alt=""/><br /><sub><b>Hamza Hamidi</b></sub></a><br /><a href="https://github.com/eta-dev/eta/commits?author=hamzahamidi" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="http://calumk.com"><img src="https://avatars1.githubusercontent.com/u/1183991?v=4" width="100px;" alt=""/><br /><sub><b>Calum Knott</b></sub></a><br /><a href="#ideas-calumk" title="Ideas, Planning, & Feedback">🤔</a></td>
</tr>
</table>

<!-- markdownlint-enable -->
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { default as compileToString } from "./compile-string.ts";
export { default as compile } from "./compile.ts";
export { default as parse } from "./parse.ts";
export { default as render } from "./render.ts";
export { default as render, renderAsync } from "./render.ts";
export { templates } from "./containers.ts";
export {
config,
Expand Down
24 changes: 23 additions & 1 deletion deno_dist/file-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,26 @@ function renderFile(
return tryHandleCache(data, renderConfig, callback);
}

export { includeFile, renderFile };
function renderFileAsync(
filename: string,
data: DataObj,
config?: PartialConfig,
cb?: CallbackFn,
): Promise<string> | void;

function renderFileAsync(
filename: string,
data: DataObj,
cb?: CallbackFn,
): Promise<string> | void;

function renderFileAsync(
filename: string,
data: DataObj,
config?: PartialConfig,
cb?: CallbackFn,
): Promise<string> | void {
return renderFile(filename, data, { ...config, async: true }, cb);
}

export { includeFile, renderFile, renderFileAsync };
3 changes: 2 additions & 1 deletion deno_dist/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ export {
loadFile,
renderFile,
renderFile as __express,
renderFileAsync,
} from "./file-handlers.ts";

/* End file stuff */

export { default as compileToString } from "./compile-string.ts";
export { default as compile } from "./compile.ts";
export { default as parse } from "./parse.ts";
export { default as render } from "./render.ts";
export { default as render, renderAsync } from "./render.ts";
export { templates } from "./containers.ts";
export {
config,
Expand Down
10 changes: 10 additions & 0 deletions deno_dist/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,13 @@ export default function render(
return handleCache(template, options)(data, options);
}
}

export function renderAsync(
template: string | TemplateFunction,
data: object,
config?: PartialConfig,
cb?: CallbackFn,
): string | Promise<string> | void {
// Using Object.assign to lower bundle size, using spread operator makes it larger
return render(template, data, Object.assign({}, config, { async: true }), cb);
}

0 comments on commit 75944e6

Please sign in to comment.