salesforce-ersa will not be maintained in this repository going forward. Please use, create issues on, and make PRs to the fork of salesforce-ersa located here.
In Greek mythology, Ersa is the daughter of Zeus who is the God of many things including Lightning.
In Salesforce, Ersa is a utility to easily show Lightning Components on a Visualforce Page.
Loading Lightning Components onto Visualforce Pages is a tedious operation that requires copying and pasting lots of boiler-plate code. You also need to roll your own handlers for Standard Lightning Events, which adds to the boiler-plate.
This utility removes the boiler-plate and enables you to write code that only pertains to the program you are developing.
-
Build a Lightning Component
-
Add the following tags to your Visualforce Page
<apex:includeLightning />
<apex:includeScript value="{!$Resource.Ersa}"/>
<div id="hello-world-lightning-component"></div>
- You should replace
hello-world-lightning-component
with a realid
here
- You should replace
-
Follow the pattern below to load the Lightning Component
<script>
Ersa.uiTheme = '{!$User.UITheme}'; // tell Ersa which UITheme you are running in
Ersa.lightningApp = 'c:HelloWorldApp'; // tell Ersa which Lightning Dependency App you created
// Add Lightning Components to load
Ersa.addLightningComponent(
'c:HelloWorld',
{accountId: '{!Account.Id}'},
'hello-world-lightning-component' // this is the id of the <div> you want the component put into
);
Ersa.loadComponents(); // loads the components
</script>
Ersa currently handles the following Standard Lighting Events
force:navigateToSObject
force:navigateToURL
force:refreshView
force:showToast
We welcome feedback and collaboration. If you see an area for improvement, feel free to send a pull request