Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for inlining Marko templates in JavaScript files using ES6 template strings #349

Closed
patrick-steele-idem opened this issue Aug 3, 2016 · 0 comments
Assignees
Labels
type:feature A feature request
Milestone

Comments

@patrick-steele-idem
Copy link
Contributor

patrick-steele-idem commented Aug 3, 2016

Example usage:

Original JavaScript file:

export default function(req, res) {
    var name = 'Frank';

    res.marko(marko`
        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta charset="UTF-8">
                <title>Hello ${name}</title>
            </head>
            <body>
                Hello ${name}!
            </body>
        </html>
        `);
}

Possible transpiled JavaScript file using a custom babel transform:

import { create as __createMarkoTemplate, helpers as __markoHelpers } from 'marko';

var markoStr = __markoHelpers.s,
  markoEmpty = __markoHelpers.e,
  markoNotEmpty = __markoHelpers.ne,
  markoEscapeXml = __markoHelpers.x;

export default function(req, res) {
    var name = 'Frank';

    res.marko(__createMarkoTemplate(__filename, function(data, out) {
        out.w(
            "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>Hello " +
            markoEscapeXml(name) +
            "</title></head><body>Hello " +
            markoEscapeXml(name) +
            "!</body></html>");
    }));
}

Related: Marko Widgets issue #152 - Proposal: Marko Widgets with ES6 and inline Marko templates

Feedback is appreciated

@patrick-steele-idem patrick-steele-idem added the type:feature A feature request label Aug 4, 2016
@patrick-steele-idem patrick-steele-idem self-assigned this Aug 19, 2016
@patrick-steele-idem patrick-steele-idem changed the title Proposal: Add support for inlining Marko templates in JavaScript files using ES6 template strings Add support for inlining Marko templates in JavaScript files using ES6 template strings Aug 19, 2016
@patrick-steele-idem patrick-steele-idem added this to the 4.0 milestone Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature A feature request
Projects
None yet
Development

No branches or pull requests

1 participant