Пример #1
0
    def _createFieldError(self, parent, token, page, modal_flag):
        """Helper for creating error alert."""

        filename = page.local
        key = token['key']
        err = alert.AlertToken(None, brand=u'error')
        alert_title = alert.AlertTitle(err,
                                       brand=u'error',
                                       string=u'Missing Template Item: "{}"'.format(key))
        alert_content = alert.AlertContent(err, brand=u'error')
        token.copyToToken(alert_content)

        if modal_flag:
            modal_content = tokens.Token(None)
            core.Paragraph(modal_content,
                           string=u"The document must include the \"{0}\" template item, this can "\
                           u"be included by add adding the following to the markdown " \
                           u"file ({1}):".format(key, filename))

            core.Code(modal_content,
                      content=u"!template! item key={0}\nInclude text (in MooseDocs format) " \
                      u"regarding the \"{0}\" template item here.\n" \
                      u"!template-end!".format(key))

            link = floats.create_modal_link(alert_title,
                                            title=u'Missing Template Item "{}"'.format(key),
                                            content=modal_content)
            materialicon.Icon(link, icon=u'help_outline',
                              class_='small',
                              style='float:right;color:white;margin-bottom:5px;')

        self.renderer.render(parent, err, page)
Пример #2
0
    def createToken(self, parent, info, page):

        sml = []
        for s in ['small', 'medium', 'large']:
            sml.append(int(self.settings[s]))
            if sml[-1] < 1 or sml[-1] > 12:
                msg = "The '{}' setting must be an integer between 1 and 12."
                raise exceptions.MooseDocsException(msg, s)

        col = ColumnToken(parent,
                          width=self.settings['width'],
                          small=sml[0],
                          medium=sml[1],
                          large=sml[2],
                          **self.attributes)

        icon = self.settings.get('icon', None)
        if icon:
            materialicon.Icon(col, icon=str(icon), class_='moose-col-icon')

        return col