Skip to content

Commit

Permalink
Update repeaters rendering example (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-elementor authored Apr 16, 2024
1 parent 8c4d311 commit 1bc23ab
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/widgets/rendering-repeaters.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {

protected function render() {
$settings = $this->get_settings_for_display();

if ( ! $settings['list'] ) {
return;
}
?>
<ul>
<?php foreach ( $settings['list'] as $index => $item ) : ?>
<li>
<?php
if ( ! $item['link']['url'] ) {
echo $item['text'];
} else {
?><a href="<?php echo esc_url( $item['link']['url'] ); ?>"><?php echo $item['text']; ?></a><?php
}
?>
<?php
if ( $item['link']['url'] ) {
?><a href="<?php echo esc_url( $item['link']['url'] ); ?>"><?php echo $item['text']; ?></a><?php
} else {
echo $item['text'];
}
?>
</li>
<?php endforeach; ?>
</ul>
Expand All @@ -81,22 +85,21 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {

protected function content_template() {
?>
<ul>
<#
if ( settings.list ) {
_.each( settings.list, function( item, index ) {
#>
<li>
<# if ( item.link && item.link.url ) { #>
<a href="{{{ item.link.url }}}">{{{ item.text }}}</a>
<# } else { #>
{{{ item.text }}}
<# } #>
</li>
<#
} );
if ( ! settings.list.length ) {
return;
}
#>
<ul>
<# _.each( settings.list, function( item, index ) { #>
<li>
<# if ( item.link && item.link.url ) { #>
<a href="{{{ item.link.url }}}">{{{ item.text }}}</a>
<# } else { #>
{{{ item.text }}}
<# } #>
</li>
<# } ); #>
</ul>
<?php
}
Expand Down

0 comments on commit 1bc23ab

Please sign in to comment.