Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Dev component scope #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
https://github.com/reactjs/react-php-v8js/pull/9
  • Loading branch information
18601673727 committed Dec 16, 2015
commit 571d8c68c25e7726ebcc12828e2534c26ec53c29
17 changes: 10 additions & 7 deletions ReactJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class ReactJS {
$component,

/**
* The Javascript scope in which React components are contained (defaults to global)
* The JavaScript scope in which React components are contained (defaults to global)
* @var string
*/
$componentScope = 'global',
$componentScope,

/**
* Properties that go along with the component
Expand Down Expand Up @@ -88,9 +88,9 @@ function setComponent($component, $data = null) {
}

/**
* Sets the Javascript scope in which React components are contained
* Sets the JavaScript scope in which React components are contained
*
* @param string $scope The Javascript scope
* @param string $scope The JavaScript scope
* @return ReactJS $this instance
*/
function setComponentScope($scope) {
Expand All @@ -116,9 +116,12 @@ function setErrorHandler($err) {
* @return string HTML string
*/
function getMarkup() {
if ($this->componentScope) {
$this->component = $this->componentScope.'.'.$this->component;
}

$js = sprintf(
"print(React.renderToString(React.createElement(%s.%s, %s)))",
$this->componentScope,
"print(React.renderToString(React.createElement(%s, %s)))",
$this->component,
$this->data);

Expand Down Expand Up @@ -163,7 +166,7 @@ function getJS($where, $return_var = null) {
}

/**
* Executes Javascript using V8JS, with primitive exception handling
* Executes JavaScript using V8JS, with primitive exception handling
*
* @param string $js JS code to be executed
* @return string The execution response
Expand Down