Skip to content

Commit

Permalink
updated: documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Dec 9, 2017
1 parent 2519c46 commit 72d8c11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Compiler Changes

### v3.3.0
- Add initial experimental sourcemaps support via `sourcemap: true` option

### v3.2.6
- Fix #105
- Fix #104

### v3.2.5
- Update dependencies and refactor some internal code avoiding bitwise operators
- Fix coffeescript parser require https://github.com/riot/compiler/pull/102
Expand Down
21 changes: 19 additions & 2 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,30 @@ var js = compiler.compile(my_tag.innerHTML, true)
After `npm install riot` you can do following:

```js
var riot = require('riot')
const riot = require('riot-compiler')
const fs = require('fs')
const tagPath = './src/components/component.tag'
const tagSource = fs.readFileSync(tagPath, 'utf8')
const options = {}

var js = compiler.compile(tag)

const js = compiler.compile(tagSource, options, tagPath)
```

The compile function takes the tag definition (string) and returns JavaScript (string).

#### Sourcemaps (experimental)

If you will compile using the `sourcemap=true` option the compiler will return an object
containing `code` and `sourcemap`. **The current riot compiler doesn't use a "real parser" so the generated sourcemaps might be inaccurate**
We will generate better sourcemap results in the next riot major release.

Here you can see how to generate sourcemaps reusing the code of the previous example:

```js
const { code, sourcemap } = compiler.compile(tagSource, { sourcemap: true }, tagPath)
```

### <a name="css-parser"></a> compiler.parsers.css [tagName, css]

Custom parsers that could be used to compile your tags CSS. For example:
Expand Down

0 comments on commit 72d8c11

Please sign in to comment.