- mounted: function() {
- // Method to replace diagrams in loaded HTML
- const replaceByDiag = (match, p1, p2) => {
- const args = this.parseFen(p2);
- return getDiagram(args);
- };
- // (AJAX) Request to get rules content (plain text, HTML)
- this.content =
- require("raw-loader!pug-plain-loader!@/rules/" +
- this.$route.params["vname"] + "/" + this.st.lang + ".pug")
- .replace(/(fen:)([^:]*):/g, replaceByDiag);
+ watch: {
+ "$route": function(newRoute) {
+ this.re_setVariant(newRoute.params["vname"]);
+ },
+ },
+ created: function() {
+ // NOTE: variant cannot be set before store is initialized
+ this.re_setVariant(this.$route.params["vname"]);
+ },
+ computed: {
+ content: function() {
+ if (!this.gameInfo.vname)
+ return ""; //variant not set yet
+ // (AJAX) Request to get rules content (plain text, HTML)
+ return require("raw-loader!@/translations/rules/" +
+ this.gameInfo.vname + "/" + this.st.lang + ".pug")
+ // Next two lines fix a weird issue after last update (2019-11)
+ .replace(/\\n/g, " ").replace(/\\"/g, '"')
+ .replace('module.exports = "', '').replace(/"$/, "")
+ .replace(/(fen:)([^:]*):/g, this.replaceByDiag);
+ },