Skip to content

Commit

Permalink
Merge pull request #59 from syumai/release-0.8.0
Browse files Browse the repository at this point in the history
Release 0.8.0
  • Loading branch information
syumai committed Jul 14, 2020
2 parents 1e6e3a6 + dd88ef7 commit 4f1b5fb
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
## Usage

```ts
import * as dejs from 'https://deno.land/x/dejs@0.7.0/mod.ts';
import * as dejs from 'https://deno.land/x/dejs@0.8.0/mod.ts';
```

- **`renderFile`**`(filePath: string, params: Params): Promise<Deno.Reader>`
Expand Down
8 changes: 5 additions & 3 deletions dem.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
{
"protocol": "https",
"path": "deno.land/std",
"version": "v0.51.0",
"version": "v0.61.0",
"files": [
"/encoding/utf8.ts",
"/io/bufio.ts",
"/io/util.ts",
"/io/readers.ts",
"/testing/asserts.ts"
]
},
Expand All @@ -18,5 +19,6 @@
"/escape.js"
]
}
]
],
"aliases": {}
}
14 changes: 10 additions & 4 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { open } = Deno;
type Reader = Deno.Reader;
import { stringsReader } from "./vendor/https/deno.land/std/io/util.ts";
import { encode } from "./vendor/https/deno.land/std/encoding/utf8.ts";
import { BufReader } from "./vendor/https/deno.land/std/io/bufio.ts";
import escape from "./vendor/https/deno.land/x/lodash/escape.js";

Expand Down Expand Up @@ -31,6 +31,12 @@ interface Template {

const decoder = new TextDecoder("utf-8");

class StringReader extends Deno.Buffer {
constructor(s: string) {
super(encode(s).buffer);
}
}

async function include(path: string, params: Params): Promise<string> {
const result = await renderFile(path, params);
const buf = new Deno.Buffer();
Expand Down Expand Up @@ -178,7 +184,7 @@ export async function renderToString(
body: string,
params: Params,
): Promise<string> {
const reader = stringsReader(body);
const reader = new StringReader(body);
const template = await compile(reader);
return template(params);
}
Expand All @@ -195,13 +201,13 @@ export async function renderFileToString(

export async function render(body: string, params: Params): Promise<Reader> {
const result = await renderToString(body, params);
return stringsReader(result);
return new StringReader(result);
}

export async function renderFile(
path: string,
params: Params,
): Promise<Reader> {
const result = await renderFileToString(path, params);
return stringsReader(result);
return new StringReader(result);
}
1 change: 1 addition & 0 deletions vendor/https/deno.land/std/encoding/utf8.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "https://deno.land/[email protected]/encoding/utf8.ts";
2 changes: 1 addition & 1 deletion vendor/https/deno.land/std/io/bufio.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'https://deno.land/std@v0.51.0/io/bufio.ts';
export * from "https://deno.land/std@v0.61.0/io/bufio.ts";
1 change: 1 addition & 0 deletions vendor/https/deno.land/std/io/readers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "https://deno.land/[email protected]/io/readers.ts";
1 change: 0 additions & 1 deletion vendor/https/deno.land/std/io/util.ts

This file was deleted.

2 changes: 1 addition & 1 deletion vendor/https/deno.land/std/testing/asserts.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'https://deno.land/std@v0.51.0/testing/asserts.ts';
export * from "https://deno.land/std@v0.61.0/testing/asserts.ts";
3 changes: 2 additions & 1 deletion vendor/https/deno.land/x/lodash/escape.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default } from 'https://deno.land/x/[email protected]/escape.js';
export * from "https://deno.land/x/[email protected]/escape.js";
export { default } from "https://deno.land/x/[email protected]/escape.js";

0 comments on commit 4f1b5fb

Please sign in to comment.