     insert: (descr) ->
         # this is the essential task of the example dialog:
         # call the callback with the selected code snippet
+        code               = @get('code')
+        setup_code         = @get('setup_code')
+        prepend_setup_code = @get('prepend_setup_code')
+        if setup_code?.length > 0 and prepend_setup_code
+            code = "#{setup_code}\n#{code}"
         data =
-            code  : @get('code')
+            code  : code
             lang  : @get('lang')
             descr : if descr then @get('descr') else null
         @get('handler')?(data)


    reduxProps :
        "#{name}" :
            show          : rtypes.bool
            lang          : rtypes.string      # the currently selected language
            lang_select   : rtypes.bool        # show buttons to allow selecting the language
            code          : rtypes.string      # displayed content of selected document
            descr         : rtypes.string      # markdown-formatted content of document description
            data          : rtypes.immutable   # this is the processed "raw" data, see Actions::load_data
            nav_entries   : rtypes.arrayOf(rtypes.string)  # languages at the top, iff lang_select is true
            catlist0      : rtypes.arrayOf(rtypes.string)  # list of first category entries
            catlist1      : rtypes.arrayOf(rtypes.string)  # list of second level categories
            catlist2      : rtypes.arrayOf(rtypes.string)  # third level are the document titles
            cat0          : rtypes.number      # index of selected first category (left)
            cat1          : rtypes.number      # index of selected second category (second from left)
            cat2          : rtypes.number      # index of selected third category (document titles)
            search_str    : rtypes.string      # substring to search for -- or undefined
            search_sel    : rtypes.number      # index of selected matched documents
            submittable   : rtypes.bool        # if true, the buttons at the bottom are active
            hits          : rtypes.arrayOf(rtypes.array)  # search results
            unknown_lang  : rtypes.bool        # true if there is no known set of documents for the language

    propTypes :
        cb      : rtypes.func

                >
                    Insert Example
                </Button>
                {
                    if @props.setup_code?.length > 0
                        <Checkbox
                            className = {'pull-right'}
                            style     = {margin: '10px', display: 'inline'}
                            checked   = {@props.prepend_setup_code}
                            onChange  = {(e)=>@handle_prepend_setup_code(e.target.checked)}
                        >
                            Setup code
                        </Checkbox>
                }
            </Modal.Footer>
        </Modal>

