Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from Pascalmh/use-instead-cset
Browse files Browse the repository at this point in the history
refactor: use function-use instead of c::set to pass variables into f…
  • Loading branch information
Pascalmh authored Feb 5, 2018
2 parents 46c766b + b6b58e1 commit c185e5b
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions kirby-responsiveimage.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
$img->attr('width', $tag->attr('width'));
$img->attr('height', $tag->attr('height'));
$img->attr('class', $tag->attr('class'));
c::set('responsiveimage.html', $img);
$html = $img;

if ($href = $tag->attr('link')) {
$link = brick('a');
Expand All @@ -61,30 +61,28 @@
$link->attr('target', '_blank');
}

$link->append(function () {
return c::get('responsiveimage.html');
$link->append(function () use ($html) {
return $html;
});

c::set('responsiveimage.html', $link);
$html = $link;
}

if (c::get('kirbytext.image.figure', true)) {
$figure = brick('figure');
$figure->append(function () {
return c::get('responsiveimage.html');
$figure->append(function () use ($html) {
return $html;
});

if ($caption = $tag->attr('caption')) {
c::set('repsonsiveimage.figure.caption', $caption);

$figure->append(function() {
return brick('figcaption', c::get('repsonsiveimage.figure.caption', false));
$figure->append(function() use ($caption) {
return brick('figcaption', $caption);
});
}

c::set('responsiveimage.html', $figure);
$html = $figure;
}

return c::get('responsiveimage.html');
return $html;
}
]);

0 comments on commit c185e5b

Please sign in to comment.