Skip to content

Commit bc49fe8

Browse files
committed
Merge branch 'master' of github.com:coldbox-modules/cbwire into development
2 parents 6fb9f4c + d1e2405 commit bc49fe8

40 files changed

+87
-51
lines changed

models/Component.cfc

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ component output="true" {
5151
*/
5252
function onDIComplete() {
5353
if ( isNull( variables._id ) ) {
54-
variables._id = hash( createUUID() );
54+
variables._id = lCase( hash( createUUID() ) );
5555
}
5656

5757
variables._params = [:];
@@ -140,12 +140,25 @@ component output="true" {
140140
return variables._CBWIREController;
141141
}
142142

143+
/**
144+
* renderIt left for backwards compatibility.
145+
*
146+
* @return string
147+
*/
148+
function renderIt() {
149+
return "";
150+
}
151+
143152
/**
144153
* Renders the component's HTML output.
145154
* This method should be overridden by subclasses to implement specific rendering logic.
146155
* If not overridden, this method will simply render the view.
147156
*/
148-
function renderIt() {
157+
function onRender() {
158+
local.renderIt = renderIt();
159+
if ( local.renderIt.len() ) {
160+
return local.renderIt;
161+
}
149162
return template( _getViewPath() );
150163
}
151164

@@ -277,7 +290,7 @@ component output="true" {
277290

278291
/**
279292
* Instantiates a CBWIRE component, mounts it,
280-
* and then calls its internal renderIt() method.
293+
* and then calls its internal onRender() method.
281294
*
282295
* This is nearly identical to the wire method defined
283296
* in the CBWIREController component, but it is intended
@@ -350,12 +363,12 @@ component output="true" {
350363
// Based on the rendering, determine our outer component tag
351364
local.componentTag = _getComponentTag( local.rendering );
352365
// Track the rendered child
353-
variables._children.append( [
366+
variables._children.append( {
354367
"#arguments.key#": [
355368
local.componentTag,
356369
local.instance._getId()
357370
]
358-
] );
371+
} );
359372

360373
return local.instance._render();
361374
}
@@ -1649,7 +1662,7 @@ component output="true" {
16491662
* Response for actually starting rendering of a component.
16501663
*/
16511664
function _render( rendering ) {
1652-
local.trimmedHTML = isNull( arguments.rendering ) ? trim( renderIt() ) : trim( arguments.rendering );
1665+
local.trimmedHTML = isNull( arguments.rendering ) ? trim( onRender() ) : trim( arguments.rendering );
16531666
// Validate the HTML content to ensure it has a single outer element
16541667
_validateSingleOuterElement( local.trimmedHTML);
16551668
// If this is the initial load, encode the snapshot and insert Livewire attributes

models/EmptySingleFileComponent.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ component extends="cbwire.models.Component" {
22

33
{{ CFC_CONTENTS }}
44

5-
function renderIt() {
5+
function onRender() {
66
return template( "{{ TEMPLATE_PATH }}" );
77
}
88

test-harness/tests/specs/CBWIRESpec.cfc

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
component extends="coldbox.system.testing.BaseTestCase" {
22

3+
function beforeAll() {
4+
super.beforeAll();
5+
// delete any files in models/tmp folder
6+
local.tempFolder = expandPath( "../../../models/tmp" );
7+
if ( directoryExists( local.tempFolder ) ) {
8+
directoryDelete( local.tempFolder, true );
9+
}
10+
directoryCreate( local.tempFolder );
11+
}
12+
313
// Lifecycle methods and BDD suites as before...
414
function run(testResults, testBox) {
515

@@ -129,18 +139,23 @@ component extends="coldbox.system.testing.BaseTestCase" {
129139
expect( parsing.snapshot.data.stringBooleanValue ).toBeTrue();
130140
});
131141

132-
it( "should render with a renderIt method", function() {
133-
var result = CBWIREController.wire( "test.should_render_with_a_renderIt_method" );
134-
expect( result ).toInclude( "<p>I rendered from renderIT</p>" );
142+
it( "should render with a onRender method", function() {
143+
var result = CBWIREController.wire( "test.should_render_with_a_onRender_method" );
144+
expect( result ).toInclude( "<p>I rendered from onRender</p>" );
145+
} );
146+
147+
it( "should render with renderIt for backwards compatibility", function() {
148+
var result = CBWIREController.wire( "test.should_render_with_renderIt_for_backwards_compatibility" );
149+
expect( result ).toInclude( "I rendered from renderIt" );
135150
} );
136151

137152
it("should implicitly render a view template", function() {
138153
var result = CBWIREController.wire( "test.should_implicitly_render_a_view_template" );
139154
expect( result ).toInclude( "<p>Implicitly rendered</p>" );
140155
} );
141156

142-
it( "should support passing params into a renderIt method", function() {
143-
var result = CBWIREController.wire( "test.should_support_passing_params_into_a_renderIt_method" );
157+
it( "should support passing params into a onRender method", function() {
158+
var result = CBWIREController.wire( "test.should_support_passing_params_into_a_onRender_method" );
144159
expect( result ).toInclude( "<p>Passed in: 5</p>" );
145160
} );
146161

@@ -178,9 +193,12 @@ component extends="coldbox.system.testing.BaseTestCase" {
178193
expect( result ).toInclude( "<p>Result: Hello World!</p>" );
179194
} );
180195

181-
it( "should support deep nesting with correct count of children", function() {
196+
xit( "should support deep nesting with correct count of children", function() {
182197
var result = CBWIREController.wire( "test.should_support_deep_nesting" );
183198
var parent = parseRendering( result, 1 );
199+
writeDump( result );
200+
writeDump( parent );
201+
abort;
184202
var child1 = parseRendering( result, 2 );
185203
var child2 = parseRendering( result, 3 );
186204
expect( parent.snapshot.memo.children.count() ).toBe( 2 );

test-harness/wires/Actions.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ component extends="cbwire.models.Component" {
1717
reset( "conference" );
1818
}
1919

20-
function renderIt(){
20+
function onRender(){
2121
return template( "wires.actions" );
2222
}
2323
}

test-harness/wires/BindingNestedData.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
component extends="cbwire.models.Component" {
22

3-
function renderIt(){
3+
function onRender(){
44
return this.renderView( "wires/bindingNestedData" );
55
}
66

test-harness/wires/ComputedProperty.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ component extends="cbwire.models.Component" {
1313
}
1414
}
1515

16-
function renderIt(){
16+
function onRender(){
1717
return this.renderView( "wires/computedProperty" );
1818
}
1919

test-harness/wires/CounterComplete.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ component extends="cbwire.models.Component" {
1919
data.counter += amount;
2020
}
2121

22-
function renderIt() {
22+
function onRender() {
2323
return template( "wires.CounterComplete", { isEven: isEven() } );
2424
}
2525
}

test-harness/wires/CounterUsingCBWIRE3.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ component extends="cbwire.models.Component" accessors="true" {
3636
* Renders the component's HTML output with Livewire-compatible attributes.
3737
* @return The HTML representation of the component, including Livewire data attributes.
3838
*/
39-
public string function renderIt() {
39+
public string function onRender() {
4040
return template("wires.CounterUsingDataDot");
4141
}
4242

test-harness/wires/DataBindingCount.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ component
88
data.count += 1;
99
}
1010

11-
function renderIt(){
11+
function onRender(){
1212
return this.renderView( "wires/dataBindingCount" );
1313
}
1414

test-harness/wires/EmitTo.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ component extends="cbwire.models.Component" {
44
this.emitTo( "wires.FireEvent2", "someEvent" );
55
}
66

7-
function renderIt(){
7+
function onRender(){
88
return this.renderView( "wires/emitTo" );
99
}
1010

0 commit comments

Comments
 (0)