Skip to content

Instantly share code, notes, and snippets.

@isapir
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save isapir/e75f1dc508b1bac1da5c to your computer and use it in GitHub Desktop.

Select an option

Save isapir/e75f1dc508b1bac1da5c to your computer and use it in GitHub Desktop.
testcase for mailing list discussion re: custom tags hierarchy
component {
/** cfc custom tag init( boolean hasEndTag, component parent ) */
function init( boolean hasEndTag, component parent ) {
this.name = listFirst(listLast(getCurrentTemplatePath(), '\/'), '.');
this.parent = arguments.parent ?: "{no-parent}";
return this;
}
/** cfc custom tag onStartTag( struct attributes, struct caller ):boolean */
boolean function onStartTag( struct attributes, struct caller ) {
if (isSimpleValue(this.parent))
echo("<p><br><br>");
echo("<p>");
echo(this.name);
echo("<span style='background-color:yellow; margin:1em; padding:0.5em;'>parent: ");
echo(isSimpleValue(this.parent) ? this.parent : listLast(getMetaData(this.parent).name, '.'));
echo("</span>");
return true;
}
}
component extends="Tag" {}
component extends="Tag" {}
component extends="Tag" {}
component extends="Tag" {}
<cf_Tag1>
<cf_Tag2>
<cf_Tag3>
<cf_Tag4>
</cf_Tag3>
</cf_Tag2>
</cf_Tag1>
<cf_Tag2>
<cfloop from="1" to="3" index="ii">
<cfoutput>
<cf_Tag4>
</cfoutput>
</cfloop>
</cf_Tag2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment