Skip to content

Commit dc18b06

Browse files
committed
Codeigniter with react code refactoring
1 parent 2c9a211 commit dc18b06

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

application/core/MY_Controller.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public function __construct() {
2727
*/
2828
protected function render_page( $view, $vars = array() ) {
2929

30-
$vars['_component_dom_tag_id'] = 'content';
30+
$vars['_module_dom_tag_id'] = 'content';
3131
$base_vars['content'] = $this->get_component( $view, $vars );
3232

33-
$vars['_component_dom_tag_id'] = 'header';
33+
$vars['_module_dom_tag_id'] = 'header';
3434
$base_vars['header'] = $this->get_component( 'header', $vars );
3535

36-
$vars['_component_dom_tag_id'] = 'footer';
36+
$vars['_module_dom_tag_id'] = 'footer';
3737
$base_vars['footer'] = $this->get_component( 'footer', $vars );
3838

3939
$this->load->view( $this->theme_base . 'base', $base_vars, FALSE );
@@ -46,7 +46,7 @@ protected function render_page( $view, $vars = array() ) {
4646
* @return [string] [HTML of the partial view]
4747
*/
4848
protected function get_component( $view, $vars = array() ) {
49-
$vars['_component_name'] = $view;
49+
$vars['_module_name'] = $view;
5050
return $this->load->view( $this->theme_base . 'content', $vars, TRUE );
5151
}
5252
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
22

33
<script type="text/babel">
4-
<?php include __DIR__ . "/react_components/{$_component_name}.jsx"; ?>
4+
<?php include __DIR__ . "/modules/{$_module_name}.jsx"; ?>
55
</script>
66

77
<?php
88
// Get component class name to render it.
9-
$component_class = str_replace('_', '', ucwords($_component_name, '_'));
9+
$module_class = str_replace('_', '', ucwords($_module_name, '_'));
1010

11-
if( strpos( $component_class, '/' ) ) {
12-
$component_class = ucwords( basename( $component_class ) );
11+
if( strpos( $module_class, '/' ) ) {
12+
$module_class = ucwords( basename( $module_class ) );
1313
}
1414
?>
1515
<script type="text/babel">
16-
ReactDOM.render( < <?php echo $component_class; ?> /> , document.getElementById( '<?php echo $_component_dom_tag_id; ?>' ) );
16+
ReactDOM.render( < <?php echo $module_class; ?> /> , document.getElementById( '<?php echo $_module_dom_tag_id; ?>' ) );
1717
</script>

0 commit comments

Comments
 (0)