1
0
Fork 0

feat(core): Added name property to parts to hold the part name

This commit is contained in:
Joost De Cock 2020-08-30 11:48:09 +02:00
parent c44bf4409e
commit 39d1cdd0ca

View file

@ -100,12 +100,14 @@ export default function Pattern(config = { options: {} }) {
} }
// Part closure // Part closure
this.Part = function () { this.Part = function (name = false) {
let part = new Part() let part = new Part()
part.context = context part.context = context
for (let macro in context.macros) { for (let macro in context.macros) {
part[macroName(macro)] = context.macros[macro] part[macroName(macro)] = context.macros[macro]
} }
if (name) part.name = name
return part return part
} }
} }
@ -155,7 +157,7 @@ Pattern.prototype.draft = function () {
this.runHooks('preDraft') this.runHooks('preDraft')
for (let partName of this.config.draftOrder) { for (let partName of this.config.draftOrder) {
if (this.debug) this.raise.debug(`Creating part \`${partName}\``) if (this.debug) this.raise.debug(`Creating part \`${partName}\``)
this.parts[partName] = new this.Part() this.parts[partName] = new this.Part(partName)
if (typeof this.config.inject[partName] === 'string') { if (typeof this.config.inject[partName] === 'string') {
if (this.debug) if (this.debug)
this.raise.debug( this.raise.debug(