feat: implement forloop.name as found in ruby shopify/liquid

This commit is contained in:
Liam Bigelow
2021-10-04 21:33:46 +08:00
committed by Jun Yang
parent 3b9c7d6fbe
commit 6dc7fada72
6 changed files with 27 additions and 9 deletions
+3 -1
View File
@@ -2,10 +2,12 @@ import { Drop } from './drop'
export class ForloopDrop extends Drop {
protected i = 0
public name: string
public length: number
public constructor (length: number) {
public constructor (length: number, collection: string, variable: string) {
super()
this.length = length
this.name = `${variable}-${collection}`
}
public next () {
this.i++
+2 -2
View File
@@ -2,8 +2,8 @@ import { ForloopDrop } from './forloop-drop'
export class TablerowloopDrop extends ForloopDrop {
private cols: number
public constructor (length: number, cols: number) {
super(length)
public constructor (length: number, cols: number, collection: string, variable: string) {
super(length, collection, variable)
this.length = length
this.cols = cols
}