GithubHelp home page GithubHelp logo

fabiofeichtinger / render-extension-loader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vtex/render-extension-loader

0.0 0.0 0.0 48 KB

JavaScript lib to fetch and render a Render extension point in a given DOM element

JavaScript 14.28% TypeScript 85.72%

render-extension-loader's Introduction

๐Ÿšง DEPRECATED - Please contact [email protected] if you need to use this. ๐Ÿ™ƒ

render-extension-loader

Use render components from the comfort of your client-side code.

Quickstart

Create an app that serves a page under /legacy-extensions/ path on myvtex.com.

// pages/pages.json
{
    "pages": {
        "legacy-getting-started": {
            "path": "/legacy-extensions/render-example",
            "theme": "theme"
        },
    },
    "extensions": {
        "legacy-getting-started": {
            "component": "index"
        },
    }
}

Assuming you're logged in the account basedevmkp and workspace loader with this app installed, you can use window.RenderExtensionLoader to load and render that extension point.

<div id="getting-started"></div>
<script>
var loader = new RenderExtensionLoader({
    account: 'basedevmkp',
    workspace: 'loader',
    path: '/render-example',
    locale: 'pt-BR',
    verbose: true,
})
loader.load().then(function (data) {
    console.log(data) // runtime
    loader.render('legacy-getting-started', document.getElementById('getting-started'))
})
</script>

You can call loader.render passing a third argument, props, which will trigger a re-render of your extension point.

Important: setting publicEndpoint when developing on staging

If you're logged in the toolbelt with a @vtex.com.br email address, you are automatically configured to use the staging environment, which serves all traffic through the alternate myvtexdev.com (as opposed to myvtex.com for prod traffic).

This means that during development, if you are linking your app in the staging environment, you must pass the publicEndpoint option to RenderExtensionLoader with the value of myvtexdev.com. Otherwise, your assets will be fetched from the production env and there might be inconsistencies during development, i.e. you will not see changes immediately.

So, during development simply pass this option to guarantee the loader will point towards the correct public endpoint:

var loader = new RenderExtensionLoader({
    account: 'basedevmkp',
    workspace: 'loader',
    path: '/render-example',
    locale: 'pt-BR',
    publicEndpoint: 'myvtexdev.com',
    verbose: true,
})

Install

From unpkg.com:

https://unpkg.com/@vtex/render-extension-loader/lib/render-extension-loader.js

render-extension-loader's People

Contributors

guifromrio avatar klzns avatar omninando avatar brunoabreu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.