mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Merge pull request #624 from tosti007/Calendar_Regex
Add Regexp possibility to titleReplace
This commit is contained in:
commit
bd277b087a
@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Russian Translation
|
||||
- Afrikaans Translation
|
||||
- Add postinstall script to notify user that MagicMirror installed successfully despite warnings from NPM.
|
||||
- Option to use RegExp in Calendar's titleReplace.
|
||||
|
||||
### Fixed
|
||||
- Update .gitignore to not ignore default modules folder.
|
||||
|
@ -379,6 +379,13 @@ Module.register("calendar", {
|
||||
titleTransform: function (title) {
|
||||
for (var needle in this.config.titleReplace) {
|
||||
var replacement = this.config.titleReplace[needle];
|
||||
|
||||
var regParts = needle.match(/^\/(.+)\/([gim]*)$/);
|
||||
if (regParts) {
|
||||
// the parsed pattern is a regexp.
|
||||
needle = new RegExp(regParts[1], regParts[2]);
|
||||
}
|
||||
|
||||
title = title.replace(needle, replacement);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user