import Immutable from "immutable" ; import Parser from "./parser" ; import TemplateBlock from "./templateBlock" ; class TemplateShortcut extends Immutable . Record ( { parsers : Immutable . Map ( ) , start : String ( ) , end : String ( ) , startTag : String ( ) , endTag : String ( ) , } , "TemplateShortcut" ) { getStart ( ) { return this . get ( "start" ) ; } getEnd ( ) { return this . get ( "end" ) ; } getStartTag ( ) { return this . get ( "startTag" ) ; } getEndTag ( ) { return this . get ( "endTag" ) ; } getParsers ( ) { return this . get ( "parsers" ) ; } param { Parser | String } parser return { boolean } acceptParser ( parser ) { if ( typeof parser !== "string" ) { parser = parser . getName ( ) ; } const parserNames = this . get ( "parsers" ) ; return parserNames . includes ( parser ) ; } param { TemplateBlock } block param { Map } details return { TemplateShortcut } static createForBlock ( block , details ) { details = Immutable . fromJS ( details ) ; return new TemplateShortcut ( { parsers : details . get ( "parsers" ) , start : details . get ( "start" ) , end : details . get ( "end" ) , startTag : block . getName ( ) , endTag : block . getEndTag ( ) , } ) ; } } export default TemplateShortcut ;