javascript - jade mixin, conditional leave out -
i'm trying make jade mixin. want omit stuff if did not input variable. maybe it's easier explain if show mean in code
mixin movie-left-image(title, posterurl, venue, rating, 3d) article h2 strong= title div div img(src = posterurl) div img(src = venue) img(src = rating) img(src = 3d)
not of info known, nor available when use mixin. instead of making amillion mixins, 1 when movie has no rating, or 1 when movie not available in 3d, i'd make 1 cover these bases.
in case, leave out 3d, want jade ignore 3d @ output. don't understand how make jade ignore 3d if leave out. or of other fields, venue or rating. in, null value, or have put of ones affected in if statements?
thanks reading.
you can try use conditional not input code don't want, in case variable not specified.
mixin movie-left-image(title, posterurl, venue, rating, 3d) article h2 strong= title div div img(src = posterurl) div img(src = venue) //- use conditionals check presence of variable if rating img(src = rating) if 3d img(src = 3d)
Comments
Post a Comment