Skip to content

Commit

Permalink
docs: update reactjs demo for consistant ES6 style
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Oct 7, 2019
1 parent cc8851e commit 4f8fc89
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
36 changes: 8 additions & 28 deletions demo/reactjs/src/App.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

let path = require('path')
let { Liquid } = require('liquidjs');

let config = require('./views/demo.liquid');
let pageConfig = config.toString()

let Parser = require('html-react-parser');
import tpl from './views/demo.liquid';
import Parser from 'html-react-parser';
import { engine } from './engine';

class App extends Component {

componentDidMount() {

let engine = new Liquid({
root: path.resolve(__dirname, 'views/'), // dirs to lookup layouts/includes
extname: '.liquid' // the extname used for layouts/includes, defaults
});

engine.registerFilter('image', d => {
let img = `<img src="${d}" class="App-logo" alt="logo"></img>`;
return img
})

engine.renderFile(pageConfig, {name: 'alice', logo: logo })
.then((htmlTemp) => {
this.setState({ html: htmlTemp })
}) // outputs "Alice"
}
async componentDidMount() {
const html = await engine.renderFile(tpl.toString(), {name: 'alice', logo: logo })
this.setState({ html }) // outputs "Alice"
}

state = {
html: []
}
state = { html: '' }

render() {
return (
Expand Down
12 changes: 12 additions & 0 deletions demo/reactjs/src/engine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import path from 'path';
import { Liquid } from 'liquidjs';

export const engine = new Liquid({
root: path.resolve(__dirname, 'views/'), // dirs to lookup layouts/includes
extname: '.liquid' // the extname used for layouts/includes, defaults
});

engine.registerFilter('image', d => {
let img = `<img src="${d}" class="App-logo" alt="logo"></img>`;
return img
})

0 comments on commit 4f8fc89

Please sign in to comment.