Skip to content

Commit 3aae420

Browse files
committed
Update documentation in README, improved FluencyMarkup rendering
1 parent 514d03b commit 3aae420

File tree

4 files changed

+302
-184
lines changed

4 files changed

+302
-184
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Fluency for ProcessWire Changelog
22

3+
## 1.0.4 2023-12-19
4+
5+
### Enhancement, Documentation
6+
7+
- Added TOC to README
8+
- Reorganized/clarified text of README for easier reading
9+
- Fixed speling mistakes in README
10+
- Expanded README to include Contributing section
11+
- Expanded README to include documentation for translating multiple strings in one call
12+
- Expanded README to include documentation for DTO methods and helpers
13+
- FluencyMarkup now accepts `null` for `$classes` parameter
14+
- FluencyMarkup now removes empty HTML attributes on render
15+
- The module method `renderLanguageLinks` now adds active class to `<li>` element containing the
16+
current page language rather than the `<a>` element contained within it.
17+
- When when a divider value is passed to `renderLanguageLinks`, the `<li>` element is given a
18+
`divider` class
19+
- Added missing parameter description to docblock for `renderLanguageLink`
20+
321
## 1.0.3 2023-12-18
422

523
### Enhancement, Documentation

Fluency.module.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,15 @@ classes: $classes,
569569
*
570570
* #pw-group-Page-And-Markup-Utilities
571571
*
572-
* @param string|array|null $classes Classes to add to <ul> element
573-
* @param string $id ID to add to <ul> element
574-
* @param string $divider String wrapped in <li> added between link <li> elements
575-
* @param string $languageSource 'fluency' to render using Fluency configured languages or
576-
* 'processwire' to render using all languages in processwire
577-
* Default: 'fluency'
572+
* @param string|array|null $classes Classes to add to <ul> element
573+
* @param string $id ID to add to <ul> element
574+
* @param string $activeClass Class added to the <li> element containing the link for the
575+
* current page.
576+
* @param string $divider String wrapped in <li> added between link <li> elements
577+
* @param string $languageSource 'fluency' to render using Fluency configured languages or
578+
* 'processwire' to render using all languages in processwire
579+
* Default: 'fluency'
578580
* @return string
579-
* @throws InvalidArgumentException
580581
*/
581582
public function renderLanguageLinks(
582583
string|array|null $classes = null,
@@ -588,24 +589,22 @@ public function renderLanguageLinks(
588589
$languages = $this->getLanguagesForMarkup($languageSource);
589590

590591
$items = array_reduce($languages, function($tags, $language) use ($activeClass, $divider) {
591-
$tags[] = Markup::a(
592-
href: $this->page->localUrl($language->id),
593-
content: $language->title,
594-
classes: $language->isCurrentLanguage ? $activeClass : null
592+
$tags[] = Markup::li(
593+
classes: $language->isCurrentLanguage ? $activeClass : null,
594+
content: Markup::a(
595+
href: $this->page->localUrl($language->id),
596+
content: $language->title,
597+
)
595598
);
596599

597-
$divider && $tags[] = $divider;
600+
$divider && $tags[] = Markup::li(content: $divider, classes: 'divider');
598601

599602
return $tags;
600603
}, []);
601604

602605
end($items) === $divider && array_pop($items);
603606

604-
return Markup::ul(
605-
items: Markup::li($items),
606-
classes: $classes ?? '',
607-
id: $id
608-
);
607+
return Markup::ul(items: $items, classes: $classes ?? '', id: $id);
609608
}
610609

611610
/**

0 commit comments

Comments
 (0)