Using Lava Remotely

Using Lava Remotely

Many people assume that Lava is limited to being used inside Rock. For the most part that is true, but we have created some neat tools to help you extend the power of Lava to other websites running alternative technologies.

Lava REST Endpoint

The Lava REST endpoint is a simple endpoint that takes Lava as input and turns the rendered template as output. This endpoint is easily used by any programming lanaguage, including Javascript.

    $lavaTemplate = "{% person id:'3' %}{{ person.FullName }} {% endperson %}";
    $apiKey = "qex8edGLGxy7mcpIIiAyIRJT";                                                                    
    $ch = curl_init("");                                                                      
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
    curl_setopt($ch, CURLOPT_POSTFIELDS, $lavaTemplate);                                                                  
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
        'Content-Type: Content-type: application/x-www-form-urlencoded; charset=UTF-8',                                                                                
        'Content-Length: ' . strlen($lavaTemplate),
        'Authorization-Token: ' . $apiKey)
    $result = curl_exec($ch);
<div id="lava-results"></div>

var lavaTemplate = "{% person id:'3' %}{{ person.FullName }} {% endperson %}";

var apiKey = 'qex8edGLGxy7mcpIIiAyIRJT';

	url: 'http://localhost:6229/api/Lava/RenderTemplate',
	data : lavaTemplate,
	type: 'POST',
	beforeSend: function (request)
		request.setRequestHeader("Authorization-Token", apiKey);
	success: function(data) {