sproutcore 1.7.1.beta → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +44 -0
- data/README.rdoc +20 -20
- data/VERSION.yml +3 -3
- data/lib/Buildfile +1 -1
- data/lib/buildtasks/build.rake +5 -0
- data/lib/buildtasks/manifest.rake +19 -1
- data/lib/frameworks/sproutcore/Buildfile +19 -17
- data/lib/frameworks/sproutcore/CHANGELOG.md +163 -29
- data/lib/frameworks/sproutcore/README.md +29 -8
- data/lib/frameworks/sproutcore/apps/statechart_routing/Buildfile +12 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/login_controller.js +11 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/main_controller.js +7 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/statechart_controller.js +17 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/core.js +25 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/main.js +15 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/_theme.css +18 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/bar_page.js +14 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/foo_page.js +14 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/loading.rhtml +9 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/login_page.js +61 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/main_page.js +46 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/statechart.js +76 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/theme.js +27 -0
- data/lib/frameworks/sproutcore/apps/tests/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/no_targets.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_detail.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_empty.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_list.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_no_tests.js +1 -1
- data/lib/frameworks/sproutcore/apps/welcome/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +14 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +15 -15
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/animation/core.js +8 -5
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +302 -70
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +19 -14
- data/lib/frameworks/sproutcore/frameworks/bootstrap/tests/system/browser.js +471 -149
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/object.js +42 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/run_loop.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/string.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/delegate_support.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/selection_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/body_overflow.js +63 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +37 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +28 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/sparse_array_delegate.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/browser.js +66 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/builder.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/cursor.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +58 -57
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js.orig +445 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +51 -31
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/ready.js +5 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +53 -69
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/responder.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +98 -72
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +37 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/timer.js +7 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +21 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/content_destroyed.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +23 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/browser.js +66 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/event.js +22 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/locale.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/end.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/escape_html.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/helpers_className.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/helpers_style.js +8 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/update.js +17 -16
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/selection_set/remove.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build_children.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/class_name_bindings_test.js +15 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createChildViews.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +50 -30
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/acceleration.js +46 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +1 -43
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +8 -34
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +10 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +6 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +22 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +0 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +35 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +46 -19
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +23 -9
- data/lib/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +2 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +294 -302
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js.orig +1531 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +14 -11
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/many_array.js +63 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +50 -10
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/destroy.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +114 -67
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/readDataHash.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/compare.js +54 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/evaluation.js +29 -9
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/parse.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/core_methods.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/flush.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/cancelRecord.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +37 -45
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/find.js +127 -127
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushChanges.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushRelationships.js +42 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/readDataHash.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +13 -7
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/resources/strings.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/debug/core.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +1 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +19 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/modal.js +30 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +24 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +121 -28
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +15 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/responder.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +39 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/collection.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/panel.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/popup_button.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -51
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +11 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-error-48.png +0 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/slider.css +0 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +9 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/content.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/reload.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/ui.js +107 -81
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowDelegate.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +68 -60
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +57 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/integration.js +21 -19
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroller.js +5 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/ui.js +32 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/methods.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/stacked/ui_comments.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +0 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +77 -132
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +5 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +16 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +52 -52
- data/lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +147 -147
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +11 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +22 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +13 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +462 -441
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +48 -62
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segment.js +22 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +150 -32
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +104 -45
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +42 -20
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +24 -24
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +148 -154
- data/lib/frameworks/sproutcore/frameworks/desktop/views/stacked.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +8 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +2 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/files.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/library.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/view_configs.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/mixins/drop_down.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/states/ready.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/views/plist_item.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/views/web.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/controllers/page_design.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/css/css_style_sheet.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/object_designer.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/view_designer.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/mixins/snap_lines.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/designer_drop_target.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/drawing.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/page_item_view.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +59 -53
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/tests/models/polymorphism/simple.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +14 -10
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu_item.js +17 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/popup_button.js +38 -14
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +5 -13
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_child.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_thumb.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/children.js +19 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/methods.js +20 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/split_thumb.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/split.js +35 -12
- data/lib/frameworks/sproutcore/frameworks/formatters/README +6 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/english.lproj/strings.js +174 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/formatters/date_formatter.js +351 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/tests/date_formatter.js +517 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +345 -138
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/button.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +176 -42
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/editable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +137 -105
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gestureable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor.js +16 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/static_layout.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/validatable.js +47 -47
- data/lib/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/helpers/sizing.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +28 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/render_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/benchmark.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/bootstrap.rhtml +34 -19
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/button_view.css +0 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/label.css +1 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +8 -9
- data/lib/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +179 -47
- data/lib/frameworks/sproutcore/frameworks/foundation/system/task_queue.js +34 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/text_selection.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/user_defaults.js +26 -12
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/misc.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +12 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_metric_optimization.js +202 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_value_support/content.js +77 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/beginEditing.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/commitEditing.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/discardEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/beginEditing.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/commitEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/discardEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/pointInElement.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +0 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +163 -149
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/credit_card.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/date.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/date_time.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/password.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/validator.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +16 -43
- data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/inline_text_field.js +67 -54
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +49 -38
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +285 -242
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffer.js +13 -13
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffered.js +19 -22
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-sc.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery.js +231 -186
- data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +145 -143
- data/lib/frameworks/sproutcore/frameworks/media/views/video.js +156 -154
- data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js.orig +540 -0
- data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +15 -8
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/base.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/replace.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/function.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/copyable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +98 -32
- data/lib/frameworks/sproutcore/frameworks/runtime/private/chain_observer.js +7 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_queue.js +14 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_set.js +98 -13
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +8 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +23 -6
- data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +69 -18
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +57 -31
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +189 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +82 -22
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/chained.js +20 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +125 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/rangeStartForIndex.js +37 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/remove.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/run_loop.js +75 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/string.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/mixins/statechart_delegate.js +113 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/private/state_path_matcher.js +312 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/async.js +18 -22
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +508 -131
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js +78 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +265 -44
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/basic/with_concurrent_states.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/responder/responder_chain.js +11 -3
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/private/state_path_matcher.js +116 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/add_substate.js +108 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/find_first_relative_current_state/with_concurrent.js +179 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/find_first_relative_current_state/without_concurrent.js +74 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/get_state.js +141 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/get_substate.js +340 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/route_triggered.js +161 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/try_to_handle_event.js +288 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/history_state/standard/without_concurrent_states/context.js +5 -33
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/routing/with_concurrent_states/basic.js +213 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/routing/without_concurrent_states/basic.js +212 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/standard/without_concurrent_states/core.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/{state/namespacing.js → statechart/methods/get_state.js} +3 -41
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/statechart/{invoke_state_method.js → methods/invoke_state_method.js} +1 -1
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/{event_handling/advanced → statechart}/respond_to_event.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/system/state_route_handler_context/methods/retry.js +64 -0
- data/lib/frameworks/sproutcore/frameworks/table/core.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/controls/button.js +0 -1
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars.js +29 -5
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/bind.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/collection.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/localization.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/view.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{handlebars → template_view}/handlebars.js +493 -357
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/mixins/template_helpers/checkbox_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/mixins/template_helpers/text_field_support.js +13 -2
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/panes/template.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/controls/button.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/mixins/template_helpers/checkbox_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/mixins/template_helpers/text_field_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/panes/template.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/collection.js +39 -14
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/core.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/handlebars.js +57 -6
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/bindable_span.js +21 -6
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/template.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/template_collection.js +55 -26
- data/lib/frameworks/sproutcore/frameworks/testing/system/equiv.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +122 -122
- data/lib/frameworks/sproutcore/frameworks/testing/system/runner.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/testing/system/suite.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/base.css +1 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/reset.css +0 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/view.css +4 -4
- data/lib/frameworks/sproutcore/lib/index.rhtml +55 -32
- data/lib/frameworks/sproutcore/license.js +2 -4
- data/lib/frameworks/sproutcore/themes/ace/resources/body.css +5 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/18px/button.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/24px/button.css +21 -13
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/30px/button.css +17 -10
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/44px/button.css +4 -3
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/24px/button.css +20 -12
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/30px/button.css +16 -8
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/jumbo/button.css +17 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/small/button.css +17 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/disclosure/ace/disclosure.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/master-detail/master-detail.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/popover.css +5 -3
- data/lib/frameworks/sproutcore/themes/iphone_theme/english.lproj/core.css +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/english.lproj/toolbar.css +1 -1
- data/lib/gen/app/USAGE +17 -4
- data/lib/gen/language/Buildfile +4 -4
- data/lib/gen/language/USAGE +4 -4
- data/lib/gen/page/templates/pages/@target_name@/Buildfile +7 -7
- data/lib/gen/{html_app → statechart_app}/Buildfile +0 -0
- data/lib/gen/{html_app → statechart_app}/README +0 -0
- data/lib/gen/statechart_app/USAGE +21 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/Buildfile +9 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/core.js +24 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/main.js +26 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/_theme.css +18 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/loading.rhtml +9 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/main_page.js +21 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/statechart.js +8 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/states/ready_state.js +12 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/theme.js +24 -0
- data/lib/sproutcore/builders.rb +1 -0
- data/lib/sproutcore/builders/base.rb +19 -1
- data/lib/sproutcore/builders/chance_file.rb +6 -1
- data/lib/sproutcore/builders/handlebars.rb +1 -9
- data/lib/sproutcore/builders/javascript.rb +1 -10
- data/lib/sproutcore/builders/json.rb +25 -0
- data/lib/sproutcore/builders/less.rb +1 -1
- data/lib/sproutcore/builders/sass.rb +1 -1
- data/lib/sproutcore/builders/stylesheet.rb +1 -9
- data/lib/sproutcore/helpers/html5_manifest.rb +1 -1
- data/lib/sproutcore/helpers/static_helper.rb +42 -0
- data/lib/sproutcore/rack/proxy.rb +21 -3
- data/lib/sproutcore/rack/service.rb +3 -2
- data/lib/sproutcore/tools.rb +18 -25
- data/lib/sproutcore/tools/gen.rb +10 -3
- data/lib/sproutcore/tools/init.rb +11 -10
- data/spec/buildtasks/manifest/prepare_build_tasks/json_spec.rb +62 -0
- data/spec/fixtures/builder_tests/apps/handlebars_test/Buildfile +1 -1
- data/spec/fixtures/builder_tests/apps/json_test/sc_static.json +2 -0
- data/spec/lib/builders/json_spec.rb +53 -0
- data/sproutcore.gemspec +2 -2
- data/vendor/chance/lib/chance/parser.rb +1 -1
- metadata +222 -177
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/datetime.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/debug/invoke_once_last_debugging.js +0 -259
- data/lib/frameworks/sproutcore/frameworks/documentation/core.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/chance.js +0 -69
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/editable/ui.js +0 -44
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/ui.js +0 -64
- data/lib/frameworks/sproutcore/frameworks/mini/license.js +0 -30
- data/lib/gen/html_app/USAGE +0 -15
- data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +0 -11
- data/lib/gen/html_app/templates/apps/@target_name@/resources/images/.gitkeep +0 -0
- data/lib/gen/html_app/templates/apps/@target_name@/resources/stylesheets/@target_name@.css +0 -6
- data/lib/gen/html_app/templates/apps/@target_name@/resources/templates/@target_name@.handlebars +0 -1
- data/lib/gen/html_project/Buildfile +0 -45
- data/lib/gen/html_project/INIT +0 -3
- data/lib/gen/html_project/README +0 -1
- data/lib/gen/html_project/USAGE +0 -2
- data/lib/gen/html_project/templates/@filename@/Buildfile +0 -5
- data/lib/gen/html_project/templates/@filename@/README +0 -4
|
@@ -7,7 +7,7 @@ var TestState;
|
|
|
7
7
|
var obj1, rootState1, stateA, stateB;
|
|
8
8
|
var obj2, rootState2, stateC, stateD;
|
|
9
9
|
|
|
10
|
-
module("SC.Statechart: invokeStateMethod Tests", {
|
|
10
|
+
module("SC.Statechart: invokeStateMethod method Tests", {
|
|
11
11
|
setup: function() {
|
|
12
12
|
TestState = SC.State.extend({
|
|
13
13
|
testInvokedCount: 0,
|
|
@@ -280,7 +280,7 @@ test("check states X, Y and Z", function() {
|
|
|
280
280
|
ok(!statechart.respondsTo('eventC'), 'statechart should not respond to event eventC');
|
|
281
281
|
});
|
|
282
282
|
|
|
283
|
-
test("try to perform 'someFunction' on statechart -- current states A", function() {
|
|
283
|
+
test("try to perform 'someFunction' on statechart -- current states A", function() {
|
|
284
284
|
ok(statechart.respondsTo('someFunction'), 'statechart should respond to someFunction');
|
|
285
285
|
ok(!statechart.get('someFunctionInvoked'), 'someFunctionInvoked should be false');
|
|
286
286
|
ok(statechart.tryToPerform('someFunction'), 'statechart should perform someFunction');
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// ==========================================================================
|
|
2
|
+
// SC.State Unit Test
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
/*globals SC externalState1 externalState2 */
|
|
5
|
+
|
|
6
|
+
var state, params, context;
|
|
7
|
+
|
|
8
|
+
module("SC.StateRouteHandlerContext: retry Method Tests", {
|
|
9
|
+
|
|
10
|
+
setup: function() {
|
|
11
|
+
|
|
12
|
+
params = { };
|
|
13
|
+
|
|
14
|
+
state = SC.Object.create({
|
|
15
|
+
|
|
16
|
+
info: {},
|
|
17
|
+
|
|
18
|
+
handler: function(params) {
|
|
19
|
+
this.info.handler = {
|
|
20
|
+
params: params
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
context = SC.StateRouteHandlerContext.create({
|
|
27
|
+
|
|
28
|
+
state: state,
|
|
29
|
+
|
|
30
|
+
params: params
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
teardown: function() {
|
|
37
|
+
params = state = context = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("Invoke retry with context's handler property assigned a function value", function() {
|
|
43
|
+
|
|
44
|
+
context.set('handler', state.handler);
|
|
45
|
+
context.retry();
|
|
46
|
+
|
|
47
|
+
var info = state.info;
|
|
48
|
+
|
|
49
|
+
ok(info.handler, "state's handler method was invoked");
|
|
50
|
+
equals(info.handler.params, params, "state's handler was provided params");
|
|
51
|
+
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("Invoke retry with context's handler property assigned a string value", function() {
|
|
55
|
+
|
|
56
|
+
context.set('handler', 'handler');
|
|
57
|
+
context.retry();
|
|
58
|
+
|
|
59
|
+
var info = state.info;
|
|
60
|
+
|
|
61
|
+
ok(info.handler, "state's handler method was invoked");
|
|
62
|
+
equals(info.handler.params, params, "state's handler was provided params");
|
|
63
|
+
|
|
64
|
+
});
|
data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars.js
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
sc_require('handlebars');
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
Prepares the Handlebars templating library for use inside SproutCore's view
|
|
3
5
|
system.
|
|
@@ -33,28 +35,50 @@ SC.Handlebars.JavaScriptCompiler.prototype.compiler = SC.Handlebars.JavaScriptCo
|
|
|
33
35
|
|
|
34
36
|
SC.Handlebars.JavaScriptCompiler.prototype.nameLookup = function(parent, name, type) {
|
|
35
37
|
if (type === 'context') {
|
|
36
|
-
return "SC.get(" + parent + ", " + this.quotedString(name) + ")
|
|
38
|
+
return "SC.get(" + parent + ", " + this.quotedString(name) + ")";
|
|
37
39
|
} else {
|
|
38
40
|
return Handlebars.JavaScriptCompiler.prototype.nameLookup.call(this, parent, name, type);
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
43
|
|
|
44
|
+
/**
|
|
45
|
+
Rewrite simple mustaches from {{foo}} to {{bind "foo"}}. This means that all simple
|
|
46
|
+
mustaches in SproutCore's Handlebars will also set up an observer to keep the DOM
|
|
47
|
+
up to date when the underlying property changes.
|
|
48
|
+
|
|
49
|
+
@private
|
|
50
|
+
*/
|
|
42
51
|
SC.Handlebars.Compiler.prototype.mustache = function(mustache) {
|
|
43
52
|
if (mustache.params.length || mustache.hash) {
|
|
44
53
|
return Handlebars.Compiler.prototype.mustache.call(this, mustache);
|
|
45
54
|
} else {
|
|
46
55
|
var id = new Handlebars.AST.IdNode(['bind']);
|
|
56
|
+
|
|
57
|
+
// Update the mustache node to include a hash value indicating whether the original node
|
|
58
|
+
// was escaped. This will allow us to properly escape values when the underlying value
|
|
59
|
+
// changes and we need to re-render the value.
|
|
60
|
+
if(mustache.escaped) {
|
|
61
|
+
mustache.hash = mustache.hash || new Handlebars.AST.HashNode([]);
|
|
62
|
+
mustache.hash.pairs.push(["escaped", new Handlebars.AST.StringNode("true")]);
|
|
63
|
+
}
|
|
47
64
|
mustache = new Handlebars.AST.MustacheNode([id].concat([mustache.id]), mustache.hash, !mustache.escaped);
|
|
48
65
|
return Handlebars.Compiler.prototype.mustache.call(this, mustache);
|
|
49
66
|
}
|
|
50
67
|
};
|
|
51
68
|
|
|
69
|
+
/**
|
|
70
|
+
The entry point for SproutCore Handlebars. This replaces the default Handlebars.compile and turns on
|
|
71
|
+
template-local data and String parameters.
|
|
72
|
+
|
|
73
|
+
@param {String} string The template to compile
|
|
74
|
+
*/
|
|
52
75
|
SC.Handlebars.compile = function(string) {
|
|
53
76
|
var ast = Handlebars.parse(string);
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
77
|
+
var options = { data: true, stringParams: true };
|
|
78
|
+
var environment = new SC.Handlebars.Compiler().compile(ast, options);
|
|
79
|
+
var templateSpec = new SC.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
|
|
80
|
+
|
|
81
|
+
return Handlebars.template(templateSpec);
|
|
58
82
|
};
|
|
59
83
|
|
|
60
84
|
/**
|
data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/bind.js
RENAMED
|
@@ -52,7 +52,8 @@ sc_require('ext/handlebars');
|
|
|
52
52
|
inverseTemplate: inverse,
|
|
53
53
|
property: property,
|
|
54
54
|
previousContext: this,
|
|
55
|
-
tagName: (options.hash.tagName || "span")
|
|
55
|
+
tagName: (options.hash.tagName || "span"),
|
|
56
|
+
isEscaped: options.hash.escaped
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
var observer, invoker;
|
|
@@ -199,13 +200,13 @@ Handlebars.registerHelper('bindAttr', function(options) {
|
|
|
199
200
|
// Do not add the attribute when the value is false
|
|
200
201
|
if (value !== NO) {
|
|
201
202
|
// Return the current value, in the form src="foo.jpg"
|
|
202
|
-
ret.push(attr+'="'+value+'"');
|
|
203
|
+
ret.push(attr + '="' + value + '"');
|
|
203
204
|
}
|
|
204
205
|
}, this);
|
|
205
206
|
|
|
206
207
|
// Add the unique identifier
|
|
207
208
|
ret.push('data-handlebars-id="'+dataId+'"');
|
|
208
|
-
return ret.join(' ');
|
|
209
|
+
return new Handlebars.SafeString(ret.join(' '));
|
|
209
210
|
});
|
|
210
211
|
|
|
211
212
|
/**
|
|
File without changes
|
|
File without changes
|
data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/view.js
RENAMED
|
File without changes
|
|
@@ -1,91 +1,192 @@
|
|
|
1
|
-
// lib/handlebars/
|
|
1
|
+
// lib/handlebars/base.js
|
|
2
|
+
var Handlebars = {};
|
|
3
|
+
|
|
4
|
+
Handlebars.VERSION = "1.0.beta.2";
|
|
5
|
+
|
|
6
|
+
Handlebars.helpers = {};
|
|
7
|
+
Handlebars.partials = {};
|
|
8
|
+
|
|
9
|
+
Handlebars.registerHelper = function(name, fn, inverse) {
|
|
10
|
+
if(inverse) { fn.not = inverse; }
|
|
11
|
+
this.helpers[name] = fn;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Handlebars.registerPartial = function(name, str) {
|
|
15
|
+
this.partials[name] = str;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Handlebars.registerHelper('helperMissing', function(arg) {
|
|
19
|
+
if(arguments.length === 2) {
|
|
20
|
+
return undefined;
|
|
21
|
+
} else {
|
|
22
|
+
throw new Error("Could not find property '" + arg + "'");
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
|
27
|
+
var inverse = options.inverse || function() {}, fn = options.fn;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var ret = "";
|
|
31
|
+
var type = Object.prototype.toString.call(context);
|
|
32
|
+
|
|
33
|
+
if(type === "[object Function]") {
|
|
34
|
+
context = context();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if(context === true) {
|
|
38
|
+
return fn(this);
|
|
39
|
+
} else if(context === false || context == null) {
|
|
40
|
+
return inverse(this);
|
|
41
|
+
} else if(type === "[object Array]") {
|
|
42
|
+
if(context.length > 0) {
|
|
43
|
+
for(var i=0, j=context.length; i<j; i++) {
|
|
44
|
+
ret = ret + fn(context[i]);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
ret = inverse(this);
|
|
48
|
+
}
|
|
49
|
+
return ret;
|
|
50
|
+
} else {
|
|
51
|
+
return fn(context);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
Handlebars.registerHelper('each', function(context, options) {
|
|
56
|
+
var fn = options.fn, inverse = options.inverse;
|
|
57
|
+
var ret = "";
|
|
58
|
+
|
|
59
|
+
if(context && context.length > 0) {
|
|
60
|
+
for(var i=0, j=context.length; i<j; i++) {
|
|
61
|
+
ret = ret + fn(context[i]);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
ret = inverse(this);
|
|
65
|
+
}
|
|
66
|
+
return ret;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
Handlebars.registerHelper('if', function(context, options) {
|
|
70
|
+
if(!context || Handlebars.Utils.isEmpty(context)) {
|
|
71
|
+
return options.inverse(this);
|
|
72
|
+
} else {
|
|
73
|
+
return options.fn(this);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
Handlebars.registerHelper('unless', function(context, options) {
|
|
78
|
+
var fn = options.fn, inverse = options.inverse;
|
|
79
|
+
options.fn = inverse;
|
|
80
|
+
options.inverse = fn;
|
|
81
|
+
|
|
82
|
+
return Handlebars.helpers['if'].call(this, context, options);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
Handlebars.registerHelper('with', function(context, options) {
|
|
86
|
+
return options.fn(context);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
Handlebars.registerHelper('log', function(context) {
|
|
90
|
+
Handlebars.log(context);
|
|
91
|
+
});
|
|
92
|
+
;
|
|
93
|
+
// lib/handlebars/compiler/parser.js
|
|
2
94
|
/* Jison generated parser */
|
|
3
95
|
var handlebars = (function(){
|
|
96
|
+
|
|
4
97
|
var parser = {trace: function trace() { },
|
|
5
98
|
yy: {},
|
|
6
|
-
symbols_: {"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"hash":26,"param":27,"STRING":28,"
|
|
7
|
-
terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",28:"STRING",
|
|
8
|
-
productions_: [0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,3],[17,2],[17,2],[17,1],[25,2],[25,1],[27,1],[27,1],[26,1],[
|
|
99
|
+
symbols_: {"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"hash":26,"param":27,"STRING":28,"INTEGER":29,"BOOLEAN":30,"hashSegments":31,"hashSegment":32,"ID":33,"EQUALS":34,"pathSegments":35,"SEP":36,"$accept":0,"$end":1},
|
|
100
|
+
terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",28:"STRING",29:"INTEGER",30:"BOOLEAN",33:"ID",34:"EQUALS",36:"SEP"},
|
|
101
|
+
productions_: [0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,3],[17,2],[17,2],[17,1],[25,2],[25,1],[27,1],[27,1],[27,1],[27,1],[26,1],[31,2],[31,1],[32,3],[32,3],[32,3],[32,3],[21,1],[35,3],[35,1]],
|
|
9
102
|
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
|
10
103
|
|
|
11
104
|
var $0 = $$.length - 1;
|
|
12
105
|
switch (yystate) {
|
|
13
|
-
case 1: return $$[$0-1]
|
|
106
|
+
case 1: return $$[$0-1]
|
|
107
|
+
break;
|
|
108
|
+
case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0])
|
|
109
|
+
break;
|
|
110
|
+
case 3: this.$ = new yy.ProgramNode($$[$0])
|
|
111
|
+
break;
|
|
112
|
+
case 4: this.$ = new yy.ProgramNode([])
|
|
113
|
+
break;
|
|
114
|
+
case 5: this.$ = [$$[$0]]
|
|
14
115
|
break;
|
|
15
|
-
case
|
|
116
|
+
case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]
|
|
16
117
|
break;
|
|
17
|
-
case
|
|
118
|
+
case 7: this.$ = new yy.InverseNode($$[$0-2], $$[$0-1], $$[$0])
|
|
18
119
|
break;
|
|
19
|
-
case
|
|
120
|
+
case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0])
|
|
20
121
|
break;
|
|
21
|
-
case
|
|
122
|
+
case 9: this.$ = $$[$0]
|
|
22
123
|
break;
|
|
23
|
-
case
|
|
124
|
+
case 10: this.$ = $$[$0]
|
|
24
125
|
break;
|
|
25
|
-
case
|
|
126
|
+
case 11: this.$ = new yy.ContentNode($$[$0])
|
|
26
127
|
break;
|
|
27
|
-
case
|
|
128
|
+
case 12: this.$ = new yy.CommentNode($$[$0])
|
|
28
129
|
break;
|
|
29
|
-
case
|
|
130
|
+
case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1])
|
|
30
131
|
break;
|
|
31
|
-
case
|
|
132
|
+
case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1])
|
|
32
133
|
break;
|
|
33
|
-
case
|
|
134
|
+
case 15: this.$ = $$[$0-1]
|
|
34
135
|
break;
|
|
35
|
-
case
|
|
136
|
+
case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1])
|
|
36
137
|
break;
|
|
37
|
-
case
|
|
138
|
+
case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true)
|
|
38
139
|
break;
|
|
39
|
-
case
|
|
140
|
+
case 18: this.$ = new yy.PartialNode($$[$0-1])
|
|
40
141
|
break;
|
|
41
|
-
case
|
|
142
|
+
case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1])
|
|
42
143
|
break;
|
|
43
|
-
case
|
|
144
|
+
case 20:
|
|
44
145
|
break;
|
|
45
|
-
case
|
|
146
|
+
case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]]
|
|
46
147
|
break;
|
|
47
|
-
case
|
|
148
|
+
case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null]
|
|
48
149
|
break;
|
|
49
|
-
case
|
|
150
|
+
case 23: this.$ = [[$$[$0-1]], $$[$0]]
|
|
50
151
|
break;
|
|
51
|
-
case
|
|
152
|
+
case 24: this.$ = [[$$[$0]], null]
|
|
52
153
|
break;
|
|
53
|
-
case
|
|
154
|
+
case 25: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
|
|
54
155
|
break;
|
|
55
|
-
case
|
|
156
|
+
case 26: this.$ = [$$[$0]]
|
|
56
157
|
break;
|
|
57
|
-
case
|
|
158
|
+
case 27: this.$ = $$[$0]
|
|
58
159
|
break;
|
|
59
|
-
case
|
|
160
|
+
case 28: this.$ = new yy.StringNode($$[$0])
|
|
60
161
|
break;
|
|
61
|
-
case
|
|
162
|
+
case 29: this.$ = new yy.IntegerNode($$[$0])
|
|
62
163
|
break;
|
|
63
|
-
case
|
|
164
|
+
case 30: this.$ = new yy.BooleanNode($$[$0])
|
|
64
165
|
break;
|
|
65
|
-
case
|
|
166
|
+
case 31: this.$ = new yy.HashNode($$[$0])
|
|
66
167
|
break;
|
|
67
|
-
case
|
|
168
|
+
case 32: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]
|
|
68
169
|
break;
|
|
69
|
-
case
|
|
170
|
+
case 33: this.$ = [$$[$0]]
|
|
70
171
|
break;
|
|
71
|
-
case
|
|
172
|
+
case 34: this.$ = [$$[$0-2], $$[$0]]
|
|
72
173
|
break;
|
|
73
|
-
case
|
|
174
|
+
case 35: this.$ = [$$[$0-2], new yy.StringNode($$[$0])]
|
|
74
175
|
break;
|
|
75
|
-
case
|
|
176
|
+
case 36: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])]
|
|
76
177
|
break;
|
|
77
|
-
case
|
|
178
|
+
case 37: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])]
|
|
78
179
|
break;
|
|
79
|
-
case
|
|
180
|
+
case 38: this.$ = new yy.IdNode($$[$0])
|
|
80
181
|
break;
|
|
81
|
-
case
|
|
182
|
+
case 39: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
|
|
82
183
|
break;
|
|
83
|
-
case
|
|
184
|
+
case 40: this.$ = [$$[$0]]
|
|
84
185
|
break;
|
|
85
186
|
}
|
|
86
187
|
},
|
|
87
|
-
table: [{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,
|
|
88
|
-
defaultActions: {16:[2,1],37:[2,23],
|
|
188
|
+
table: [{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,33:[1,25],35:24},{17:26,21:23,33:[1,25],35:24},{17:27,21:23,33:[1,25],35:24},{17:28,21:23,33:[1,25],35:24},{21:29,33:[1,25],35:24},{1:[2,1]},{6:30,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,31],21:23,33:[1,25],35:24},{10:32,20:[1,33]},{10:34,20:[1,33]},{18:[1,35]},{18:[2,24],21:40,25:36,26:37,27:38,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,38],28:[2,38],29:[2,38],30:[2,38],33:[2,38],36:[1,46]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],36:[2,40]},{18:[1,47]},{18:[1,48]},{18:[1,49]},{18:[1,50],21:51,33:[1,25],35:24},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:52,33:[1,25],35:24},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,22],21:40,26:53,27:54,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,23]},{18:[2,26],28:[2,26],29:[2,26],30:[2,26],33:[2,26]},{18:[2,31],32:55,33:[1,56]},{18:[2,27],28:[2,27],29:[2,27],30:[2,27],33:[2,27]},{18:[2,28],28:[2,28],29:[2,28],30:[2,28],33:[2,28]},{18:[2,29],28:[2,29],29:[2,29],30:[2,29],33:[2,29]},{18:[2,30],28:[2,30],29:[2,30],30:[2,30],33:[2,30]},{18:[2,33],33:[2,33]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],34:[1,57],36:[2,40]},{33:[1,58]},{14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]},{18:[1,59]},{18:[1,60]},{18:[2,21]},{18:[2,25],28:[2,25],29:[2,25],30:[2,25],33:[2,25]},{18:[2,32],33:[2,32]},{34:[1,57]},{21:61,28:[1,62],29:[1,63],30:[1,64],33:[1,25],35:24},{18:[2,39],28:[2,39],29:[2,39],30:[2,39],33:[2,39],36:[2,39]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]},{18:[2,34],33:[2,34]},{18:[2,35],33:[2,35]},{18:[2,36],33:[2,36]},{18:[2,37],33:[2,37]}],
|
|
189
|
+
defaultActions: {16:[2,1],37:[2,23],53:[2,21]},
|
|
89
190
|
parseError: function parseError(str, hash) {
|
|
90
191
|
throw new Error(str);
|
|
91
192
|
},
|
|
@@ -107,6 +208,8 @@ parse: function parse(input) {
|
|
|
107
208
|
this.lexer.setInput(input);
|
|
108
209
|
this.lexer.yy = this.yy;
|
|
109
210
|
this.yy.lexer = this.lexer;
|
|
211
|
+
if (typeof this.lexer.yylloc == 'undefined')
|
|
212
|
+
this.lexer.yylloc = {};
|
|
110
213
|
var yyloc = this.lexer.yylloc;
|
|
111
214
|
lstack.push(yyloc);
|
|
112
215
|
|
|
@@ -191,7 +294,7 @@ parse: function parse(input) {
|
|
|
191
294
|
popStack(1);
|
|
192
295
|
state = stack[stack.length-1];
|
|
193
296
|
}
|
|
194
|
-
|
|
297
|
+
|
|
195
298
|
preErrorSymbol = symbol; // save the lookahead token
|
|
196
299
|
symbol = TERROR; // insert generic error symbol as new lookahead
|
|
197
300
|
state = stack[stack.length-1];
|
|
@@ -270,7 +373,9 @@ parse: function parse(input) {
|
|
|
270
373
|
|
|
271
374
|
return true;
|
|
272
375
|
}};/* Jison generated lexer */
|
|
273
|
-
var lexer = (function(){
|
|
376
|
+
var lexer = (function(){
|
|
377
|
+
|
|
378
|
+
var lexer = ({EOF:1,
|
|
274
379
|
parseError:function parseError(str, hash) {
|
|
275
380
|
if (this.yy.parseError) {
|
|
276
381
|
this.yy.parseError(str, hash);
|
|
@@ -345,7 +450,7 @@ next:function () {
|
|
|
345
450
|
this.yylloc = {first_line: this.yylloc.last_line,
|
|
346
451
|
last_line: this.yylineno+1,
|
|
347
452
|
first_column: this.yylloc.last_column,
|
|
348
|
-
last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match.length}
|
|
453
|
+
last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
|
|
349
454
|
this.yytext += match[0];
|
|
350
455
|
this.match += match[0];
|
|
351
456
|
this.matches = match;
|
|
@@ -361,7 +466,7 @@ next:function () {
|
|
|
361
466
|
if (this._input === "") {
|
|
362
467
|
return this.EOF;
|
|
363
468
|
} else {
|
|
364
|
-
this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
|
|
469
|
+
this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
|
|
365
470
|
{text: "", token: null, line: this.yylineno});
|
|
366
471
|
}
|
|
367
472
|
},
|
|
@@ -386,60 +491,66 @@ lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_STA
|
|
|
386
491
|
|
|
387
492
|
var YYSTATE=YY_START
|
|
388
493
|
switch($avoiding_name_collisions) {
|
|
389
|
-
case 0: this.begin("mu"); if (yy_.yytext) return 14;
|
|
494
|
+
case 0: this.begin("mu"); if (yy_.yytext) return 14;
|
|
495
|
+
break;
|
|
496
|
+
case 1: return 14;
|
|
497
|
+
break;
|
|
498
|
+
case 2: return 24;
|
|
499
|
+
break;
|
|
500
|
+
case 3: return 16;
|
|
390
501
|
break;
|
|
391
|
-
case
|
|
502
|
+
case 4: return 20;
|
|
392
503
|
break;
|
|
393
|
-
case
|
|
504
|
+
case 5: return 19;
|
|
394
505
|
break;
|
|
395
|
-
case
|
|
506
|
+
case 6: return 19;
|
|
396
507
|
break;
|
|
397
|
-
case
|
|
508
|
+
case 7: return 23;
|
|
398
509
|
break;
|
|
399
|
-
case
|
|
510
|
+
case 8: return 23;
|
|
400
511
|
break;
|
|
401
|
-
case
|
|
512
|
+
case 9: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.begin("INITIAL"); return 15;
|
|
402
513
|
break;
|
|
403
|
-
case
|
|
514
|
+
case 10: return 22;
|
|
404
515
|
break;
|
|
405
|
-
case
|
|
516
|
+
case 11: return 34;
|
|
406
517
|
break;
|
|
407
|
-
case
|
|
518
|
+
case 12: return 33;
|
|
408
519
|
break;
|
|
409
|
-
case
|
|
520
|
+
case 13: return 33;
|
|
410
521
|
break;
|
|
411
|
-
case
|
|
522
|
+
case 14: return 36;
|
|
412
523
|
break;
|
|
413
|
-
case
|
|
524
|
+
case 15: /*ignore whitespace*/
|
|
414
525
|
break;
|
|
415
|
-
case
|
|
526
|
+
case 16: this.begin("INITIAL"); return 18;
|
|
416
527
|
break;
|
|
417
|
-
case
|
|
528
|
+
case 17: this.begin("INITIAL"); return 18;
|
|
418
529
|
break;
|
|
419
|
-
case
|
|
530
|
+
case 18: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 28;
|
|
420
531
|
break;
|
|
421
|
-
case
|
|
532
|
+
case 19: return 30;
|
|
422
533
|
break;
|
|
423
|
-
case
|
|
534
|
+
case 20: return 30;
|
|
424
535
|
break;
|
|
425
|
-
case
|
|
536
|
+
case 21: return 29;
|
|
426
537
|
break;
|
|
427
|
-
case
|
|
538
|
+
case 22: return 33;
|
|
428
539
|
break;
|
|
429
|
-
case
|
|
540
|
+
case 23: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 33;
|
|
430
541
|
break;
|
|
431
|
-
case
|
|
542
|
+
case 24: return 'INVALID';
|
|
543
|
+
break;
|
|
544
|
+
case 25: return 5;
|
|
432
545
|
break;
|
|
433
546
|
}
|
|
434
547
|
};
|
|
435
|
-
lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{
|
|
436
|
-
lexer.conditions = {"mu":{"rules":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21],"inclusive":false},"INITIAL":{"rules":[0,1,
|
|
548
|
+
lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s/.])/,/^\[.*\]/,/^./,/^$/];
|
|
549
|
+
lexer.conditions = {"mu":{"rules":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"inclusive":false},"INITIAL":{"rules":[0,1,25],"inclusive":true}};return lexer;})()
|
|
437
550
|
parser.lexer = lexer;
|
|
438
551
|
return parser;
|
|
439
|
-
})()
|
|
440
|
-
// lib/handlebars/base.js
|
|
441
|
-
var Handlebars = {};
|
|
442
|
-
|
|
552
|
+
})();;
|
|
553
|
+
// lib/handlebars/compiler/base.js
|
|
443
554
|
Handlebars.Parser = handlebars;
|
|
444
555
|
|
|
445
556
|
Handlebars.parse = function(string) {
|
|
@@ -451,101 +562,6 @@ Handlebars.print = function(ast) {
|
|
|
451
562
|
return new Handlebars.PrintVisitor().accept(ast);
|
|
452
563
|
};
|
|
453
564
|
|
|
454
|
-
Handlebars.Runtime = {};
|
|
455
|
-
|
|
456
|
-
Handlebars.Runtime.compile = function(string) {
|
|
457
|
-
var ast = Handlebars.parse(string);
|
|
458
|
-
|
|
459
|
-
return function(context, helpers, partials) {
|
|
460
|
-
helpers = helpers || Handlebars.helpers;
|
|
461
|
-
partials = partials || Handlebars.partials;
|
|
462
|
-
|
|
463
|
-
var internalContext = new Handlebars.Context(context, helpers, partials);
|
|
464
|
-
var runtime = new Handlebars.Runtime(internalContext);
|
|
465
|
-
runtime.accept(ast);
|
|
466
|
-
return runtime.buffer;
|
|
467
|
-
};
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
Handlebars.helpers = {};
|
|
471
|
-
Handlebars.partials = {};
|
|
472
|
-
|
|
473
|
-
Handlebars.registerHelper = function(name, fn, inverse) {
|
|
474
|
-
if(inverse) { fn.not = inverse; }
|
|
475
|
-
this.helpers[name] = fn;
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
Handlebars.registerPartial = function(name, str) {
|
|
479
|
-
this.partials[name] = str;
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
Handlebars.registerHelper('helperMissing', function(arg) {
|
|
483
|
-
if(arguments.length === 2) {
|
|
484
|
-
return undefined;
|
|
485
|
-
} else {
|
|
486
|
-
throw new Error("Could not find property '" + arg + "'");
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
Handlebars.registerHelper('blockHelperMissing', function(context, fn, inverse) {
|
|
491
|
-
inverse = inverse || function() {};
|
|
492
|
-
|
|
493
|
-
var ret = "";
|
|
494
|
-
var type = Object.prototype.toString.call(context);
|
|
495
|
-
|
|
496
|
-
if(type === "[object Function]") {
|
|
497
|
-
context = context();
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if(context === true) {
|
|
501
|
-
return fn(this);
|
|
502
|
-
} else if(context === false || context == null) {
|
|
503
|
-
return inverse(this);
|
|
504
|
-
} else if(type === "[object Array]") {
|
|
505
|
-
if(context.length > 0) {
|
|
506
|
-
for(var i=0, j=context.length; i<j; i++) {
|
|
507
|
-
ret = ret + fn(context[i]);
|
|
508
|
-
}
|
|
509
|
-
} else {
|
|
510
|
-
ret = inverse(this);
|
|
511
|
-
}
|
|
512
|
-
return ret;
|
|
513
|
-
} else {
|
|
514
|
-
return fn(context);
|
|
515
|
-
}
|
|
516
|
-
}, function(context, fn) {
|
|
517
|
-
return fn(context);
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
Handlebars.registerHelper('each', function(context, fn, inverse) {
|
|
521
|
-
var ret = "";
|
|
522
|
-
|
|
523
|
-
if(context && context.length > 0) {
|
|
524
|
-
for(var i=0, j=context.length; i<j; i++) {
|
|
525
|
-
ret = ret + fn(context[i]);
|
|
526
|
-
}
|
|
527
|
-
} else {
|
|
528
|
-
ret = inverse(this);
|
|
529
|
-
}
|
|
530
|
-
return ret;
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
Handlebars.registerHelper('if', function(context, fn, inverse) {
|
|
534
|
-
if(!context || context == []) {
|
|
535
|
-
return inverse(this);
|
|
536
|
-
} else {
|
|
537
|
-
return fn(this);
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
Handlebars.registerHelper('unless', function(context, fn, inverse) {
|
|
542
|
-
return Handlebars.helpers['if'].call(this, context, inverse, fn);
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
Handlebars.registerHelper('with', function(context, fn) {
|
|
546
|
-
return fn(context);
|
|
547
|
-
});
|
|
548
|
-
|
|
549
565
|
Handlebars.logger = {
|
|
550
566
|
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
|
551
567
|
|
|
@@ -555,7 +571,7 @@ Handlebars.logger = {
|
|
|
555
571
|
|
|
556
572
|
Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
|
|
557
573
|
;
|
|
558
|
-
// lib/handlebars/ast.js
|
|
574
|
+
// lib/handlebars/compiler/ast.js
|
|
559
575
|
(function() {
|
|
560
576
|
|
|
561
577
|
Handlebars.AST = {};
|
|
@@ -623,7 +639,7 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
|
|
|
623
639
|
var part = parts[i];
|
|
624
640
|
|
|
625
641
|
if(part === "..") { depth++; }
|
|
626
|
-
else if(part === "." || part === "this") {
|
|
642
|
+
else if(part === "." || part === "this") { this.isScoped = true; }
|
|
627
643
|
else { dig.push(part); }
|
|
628
644
|
}
|
|
629
645
|
|
|
@@ -638,25 +654,31 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
|
|
|
638
654
|
this.string = string;
|
|
639
655
|
};
|
|
640
656
|
|
|
657
|
+
Handlebars.AST.IntegerNode = function(integer) {
|
|
658
|
+
this.type = "INTEGER";
|
|
659
|
+
this.integer = integer;
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
Handlebars.AST.BooleanNode = function(bool) {
|
|
663
|
+
this.type = "BOOLEAN";
|
|
664
|
+
this.bool = bool;
|
|
665
|
+
};
|
|
666
|
+
|
|
641
667
|
Handlebars.AST.CommentNode = function(comment) {
|
|
642
668
|
this.type = "comment";
|
|
643
669
|
this.comment = comment;
|
|
644
670
|
};
|
|
645
671
|
|
|
646
672
|
})();;
|
|
647
|
-
// lib/handlebars/visitor.js
|
|
648
|
-
|
|
649
|
-
Handlebars.Visitor = function() {};
|
|
650
|
-
|
|
651
|
-
Handlebars.Visitor.prototype = {
|
|
652
|
-
accept: function(object) {
|
|
653
|
-
return this[object.type](object);
|
|
654
|
-
}
|
|
655
|
-
};;
|
|
656
673
|
// lib/handlebars/utils.js
|
|
657
674
|
Handlebars.Exception = function(message) {
|
|
658
|
-
|
|
675
|
+
var tmp = Error.prototype.constructor.apply(this, arguments);
|
|
676
|
+
|
|
677
|
+
for (var p in tmp) {
|
|
678
|
+
if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
|
|
679
|
+
}
|
|
659
680
|
};
|
|
681
|
+
Handlebars.Exception.prototype = new Error;
|
|
660
682
|
|
|
661
683
|
// Build out our basic SafeString type
|
|
662
684
|
Handlebars.SafeString = function(string) {
|
|
@@ -669,14 +691,17 @@ Handlebars.SafeString.prototype.toString = function() {
|
|
|
669
691
|
(function() {
|
|
670
692
|
var escape = {
|
|
671
693
|
"<": "<",
|
|
672
|
-
">": ">"
|
|
694
|
+
">": ">",
|
|
695
|
+
'"': """,
|
|
696
|
+
"'": "'",
|
|
697
|
+
"`": "`"
|
|
673
698
|
};
|
|
674
699
|
|
|
675
|
-
var badChars = /&(?!\w+;)|[<>]/g;
|
|
676
|
-
var possible = /[&<>]
|
|
700
|
+
var badChars = /&(?!\w+;)|[<>"'`]/g;
|
|
701
|
+
var possible = /[&<>"'`]/;
|
|
677
702
|
|
|
678
703
|
var escapeChar = function(chr) {
|
|
679
|
-
return escape[chr] || "&"
|
|
704
|
+
return escape[chr] || "&";
|
|
680
705
|
};
|
|
681
706
|
|
|
682
707
|
Handlebars.Utils = {
|
|
@@ -707,7 +732,7 @@ Handlebars.SafeString.prototype.toString = function() {
|
|
|
707
732
|
}
|
|
708
733
|
};
|
|
709
734
|
})();;
|
|
710
|
-
// lib/handlebars/
|
|
735
|
+
// lib/handlebars/compiler/compiler.js
|
|
711
736
|
Handlebars.Compiler = function() {};
|
|
712
737
|
Handlebars.JavaScriptCompiler = function() {};
|
|
713
738
|
|
|
@@ -726,7 +751,6 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
726
751
|
invokeProgram: 11,
|
|
727
752
|
invokePartial: 12,
|
|
728
753
|
push: 13,
|
|
729
|
-
invokeInverse: 14,
|
|
730
754
|
assignToHash: 15,
|
|
731
755
|
pushStringParam: 16
|
|
732
756
|
};
|
|
@@ -734,16 +758,15 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
734
758
|
Compiler.MULTI_PARAM_OPCODES = {
|
|
735
759
|
appendContent: 1,
|
|
736
760
|
getContext: 1,
|
|
737
|
-
lookupWithHelpers:
|
|
761
|
+
lookupWithHelpers: 2,
|
|
738
762
|
lookup: 1,
|
|
739
|
-
invokeMustache:
|
|
763
|
+
invokeMustache: 3,
|
|
740
764
|
pushString: 1,
|
|
741
765
|
truthyOrFallback: 1,
|
|
742
766
|
functionOrFallback: 1,
|
|
743
|
-
invokeProgram:
|
|
767
|
+
invokeProgram: 3,
|
|
744
768
|
invokePartial: 1,
|
|
745
769
|
push: 1,
|
|
746
|
-
invokeInverse: 1,
|
|
747
770
|
assignToHash: 1,
|
|
748
771
|
pushStringParam: 1
|
|
749
772
|
};
|
|
@@ -803,7 +826,25 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
803
826
|
compile: function(program, options) {
|
|
804
827
|
this.children = [];
|
|
805
828
|
this.depths = {list: []};
|
|
806
|
-
this.options = options
|
|
829
|
+
this.options = options;
|
|
830
|
+
|
|
831
|
+
// These changes will propagate to the other compiler components
|
|
832
|
+
var knownHelpers = this.options.knownHelpers;
|
|
833
|
+
this.options.knownHelpers = {
|
|
834
|
+
'helperMissing': true,
|
|
835
|
+
'blockHelperMissing': true,
|
|
836
|
+
'each': true,
|
|
837
|
+
'if': true,
|
|
838
|
+
'unless': true,
|
|
839
|
+
'with': true,
|
|
840
|
+
'log': true
|
|
841
|
+
};
|
|
842
|
+
if (knownHelpers) {
|
|
843
|
+
for (var name in knownHelpers) {
|
|
844
|
+
this.options.knownHelpers[name] = knownHelpers[name];
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
807
848
|
return this.program(program);
|
|
808
849
|
},
|
|
809
850
|
|
|
@@ -819,6 +860,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
819
860
|
statement = statements[i];
|
|
820
861
|
this[statement.type](statement);
|
|
821
862
|
}
|
|
863
|
+
this.isSimple = l === 1;
|
|
822
864
|
|
|
823
865
|
this.depths.list = this.depths.list.sort(function(a, b) {
|
|
824
866
|
return a - b;
|
|
@@ -858,16 +900,19 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
858
900
|
this.declare('inverse', inverseGuid);
|
|
859
901
|
}
|
|
860
902
|
|
|
861
|
-
this.opcode('invokeProgram', programGuid, params.length);
|
|
903
|
+
this.opcode('invokeProgram', programGuid, params.length, !!mustache.hash);
|
|
862
904
|
this.declare('inverse', null);
|
|
863
905
|
this.opcode('append');
|
|
864
906
|
},
|
|
865
907
|
|
|
866
908
|
inverse: function(block) {
|
|
867
|
-
this.
|
|
909
|
+
var params = this.setupStackForMustache(block.mustache);
|
|
910
|
+
|
|
868
911
|
var programGuid = this.compileProgram(block.program);
|
|
869
912
|
|
|
870
|
-
this.
|
|
913
|
+
this.declare('inverse', programGuid);
|
|
914
|
+
|
|
915
|
+
this.opcode('invokeProgram', null, params.length, !!block.mustache.hash);
|
|
871
916
|
this.opcode('append');
|
|
872
917
|
},
|
|
873
918
|
|
|
@@ -892,7 +937,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
892
937
|
if(partial.context) {
|
|
893
938
|
this.ID(partial.context);
|
|
894
939
|
} else {
|
|
895
|
-
this.opcode('push', '
|
|
940
|
+
this.opcode('push', 'depth0');
|
|
896
941
|
}
|
|
897
942
|
|
|
898
943
|
this.opcode('invokePartial', id.original);
|
|
@@ -906,7 +951,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
906
951
|
mustache: function(mustache) {
|
|
907
952
|
var params = this.setupStackForMustache(mustache);
|
|
908
953
|
|
|
909
|
-
this.opcode('invokeMustache', params.length, mustache.id.original);
|
|
954
|
+
this.opcode('invokeMustache', params.length, mustache.id.original, !!mustache.hash);
|
|
910
955
|
|
|
911
956
|
if(mustache.escaped) {
|
|
912
957
|
this.opcode('appendEscaped');
|
|
@@ -920,7 +965,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
920
965
|
|
|
921
966
|
this.opcode('getContext', id.depth);
|
|
922
967
|
|
|
923
|
-
this.opcode('lookupWithHelpers', id.parts[0] || null);
|
|
968
|
+
this.opcode('lookupWithHelpers', id.parts[0] || null, id.isScoped || false);
|
|
924
969
|
|
|
925
970
|
for(var i=1, l=id.parts.length; i<l; i++) {
|
|
926
971
|
this.opcode('lookup', id.parts[i]);
|
|
@@ -931,6 +976,14 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
931
976
|
this.opcode('pushString', string.string);
|
|
932
977
|
},
|
|
933
978
|
|
|
979
|
+
INTEGER: function(integer) {
|
|
980
|
+
this.opcode('push', integer.integer);
|
|
981
|
+
},
|
|
982
|
+
|
|
983
|
+
BOOLEAN: function(bool) {
|
|
984
|
+
this.opcode('push', bool.bool);
|
|
985
|
+
},
|
|
986
|
+
|
|
934
987
|
comment: function() {},
|
|
935
988
|
|
|
936
989
|
// HELPERS
|
|
@@ -953,10 +1006,11 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
953
1006
|
}
|
|
954
1007
|
},
|
|
955
1008
|
|
|
956
|
-
opcode: function(name, val1, val2) {
|
|
1009
|
+
opcode: function(name, val1, val2, val3) {
|
|
957
1010
|
this.opcodes.push(Compiler.OPCODE_MAP[name]);
|
|
958
1011
|
if(val1 !== undefined) { this.opcodes.push(val1); }
|
|
959
1012
|
if(val2 !== undefined) { this.opcodes.push(val2); }
|
|
1013
|
+
if(val3 !== undefined) { this.opcodes.push(val3); }
|
|
960
1014
|
},
|
|
961
1015
|
|
|
962
1016
|
declare: function(name, value) {
|
|
@@ -981,8 +1035,6 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
981
1035
|
|
|
982
1036
|
if(mustache.hash) {
|
|
983
1037
|
this.hash(mustache.hash);
|
|
984
|
-
} else {
|
|
985
|
-
this.opcode('push', '{}');
|
|
986
1038
|
}
|
|
987
1039
|
|
|
988
1040
|
this.ID(mustache.id);
|
|
@@ -995,37 +1047,51 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
995
1047
|
// PUBLIC API: You can override these methods in a subclass to provide
|
|
996
1048
|
// alternative compiled forms for name lookup and buffering semantics
|
|
997
1049
|
nameLookup: function(parent, name, type) {
|
|
998
|
-
|
|
999
|
-
return parent + "[
|
|
1000
|
-
} else {
|
|
1001
|
-
|
|
1050
|
+
if (/^[0-9]+$/.test(name)) {
|
|
1051
|
+
return parent + "[" + name + "]";
|
|
1052
|
+
} else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
|
|
1053
|
+
return parent + "." + name;
|
|
1054
|
+
}
|
|
1055
|
+
else {
|
|
1056
|
+
return parent + "['" + name + "']";
|
|
1002
1057
|
}
|
|
1003
1058
|
},
|
|
1004
1059
|
|
|
1005
1060
|
appendToBuffer: function(string) {
|
|
1006
|
-
|
|
1061
|
+
if (this.environment.isSimple) {
|
|
1062
|
+
return "return " + string + ";";
|
|
1063
|
+
} else {
|
|
1064
|
+
return "buffer += " + string + ";";
|
|
1065
|
+
}
|
|
1007
1066
|
},
|
|
1008
1067
|
|
|
1009
1068
|
initializeBuffer: function() {
|
|
1010
1069
|
return this.quotedString("");
|
|
1011
1070
|
},
|
|
1071
|
+
|
|
1072
|
+
namespace: "Handlebars",
|
|
1012
1073
|
// END PUBLIC API
|
|
1013
1074
|
|
|
1014
|
-
compile: function(environment, options) {
|
|
1075
|
+
compile: function(environment, options, context, asObject) {
|
|
1015
1076
|
this.environment = environment;
|
|
1016
1077
|
this.options = options || {};
|
|
1017
1078
|
|
|
1079
|
+
this.name = this.environment.name;
|
|
1080
|
+
this.isChild = !!context;
|
|
1081
|
+
this.context = context || {
|
|
1082
|
+
programs: [],
|
|
1083
|
+
aliases: { self: 'this' },
|
|
1084
|
+
registers: {list: []}
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1018
1087
|
this.preamble();
|
|
1019
1088
|
|
|
1020
1089
|
this.stackSlot = 0;
|
|
1021
1090
|
this.stackVars = [];
|
|
1022
|
-
this.registers = {list: []};
|
|
1023
1091
|
|
|
1024
1092
|
this.compileChildren(environment, options);
|
|
1025
1093
|
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
var opcodes = environment.opcodes, opcode, name, declareName, declareVal;
|
|
1094
|
+
var opcodes = environment.opcodes, opcode;
|
|
1029
1095
|
|
|
1030
1096
|
this.i = 0;
|
|
1031
1097
|
|
|
@@ -1041,7 +1107,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1041
1107
|
}
|
|
1042
1108
|
}
|
|
1043
1109
|
|
|
1044
|
-
return this.
|
|
1110
|
+
return this.createFunctionContext(asObject);
|
|
1045
1111
|
},
|
|
1046
1112
|
|
|
1047
1113
|
nextOpcode: function(n) {
|
|
@@ -1072,11 +1138,21 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1072
1138
|
|
|
1073
1139
|
preamble: function() {
|
|
1074
1140
|
var out = [];
|
|
1075
|
-
out.push("var buffer = " + this.initializeBuffer() + ", currentContext = context");
|
|
1076
1141
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1142
|
+
if (!this.isChild) {
|
|
1143
|
+
var namespace = this.namespace;
|
|
1144
|
+
var copies = "helpers = helpers || " + namespace + ".helpers;";
|
|
1145
|
+
if(this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
|
|
1146
|
+
out.push(copies);
|
|
1147
|
+
} else {
|
|
1148
|
+
out.push('');
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
if (!this.environment.isSimple) {
|
|
1152
|
+
out.push(", buffer = " + this.initializeBuffer());
|
|
1153
|
+
} else {
|
|
1154
|
+
out.push("");
|
|
1155
|
+
}
|
|
1080
1156
|
|
|
1081
1157
|
// track the last context pushed into place to allow skipping the
|
|
1082
1158
|
// getContext opcode when it would be a noop
|
|
@@ -1084,65 +1160,52 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1084
1160
|
this.source = out;
|
|
1085
1161
|
},
|
|
1086
1162
|
|
|
1087
|
-
|
|
1088
|
-
var
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
program: function(i, helpers, partials, data) {
|
|
1093
|
-
var programWrapper = this.programs[i];
|
|
1094
|
-
if(data) {
|
|
1095
|
-
return Handlebars.VM.program(this.children[i], helpers, partials, data);
|
|
1096
|
-
} else if(programWrapper) {
|
|
1097
|
-
return programWrapper;
|
|
1098
|
-
} else {
|
|
1099
|
-
programWrapper = this.programs[i] = Handlebars.VM.program(this.children[i], helpers, partials);
|
|
1100
|
-
return programWrapper;
|
|
1101
|
-
}
|
|
1102
|
-
},
|
|
1103
|
-
programWithDepth: Handlebars.VM.programWithDepth,
|
|
1104
|
-
noop: Handlebars.VM.noop
|
|
1105
|
-
};
|
|
1106
|
-
var locals = this.stackVars.concat(this.registers.list);
|
|
1163
|
+
createFunctionContext: function(asObject) {
|
|
1164
|
+
var locals = this.stackVars;
|
|
1165
|
+
if (!this.isChild) {
|
|
1166
|
+
locals = locals.concat(this.context.registers.list);
|
|
1167
|
+
}
|
|
1107
1168
|
|
|
1108
1169
|
if(locals.length > 0) {
|
|
1109
|
-
this.source[
|
|
1170
|
+
this.source[1] = this.source[1] + ", " + locals.join(", ");
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// Generate minimizer alias mappings
|
|
1174
|
+
if (!this.isChild) {
|
|
1175
|
+
var aliases = []
|
|
1176
|
+
for (var alias in this.context.aliases) {
|
|
1177
|
+
this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
|
|
1178
|
+
}
|
|
1110
1179
|
}
|
|
1111
1180
|
|
|
1112
|
-
|
|
1181
|
+
if (this.source[1]) {
|
|
1182
|
+
this.source[1] = "var " + this.source[1].substring(2) + ";";
|
|
1183
|
+
}
|
|
1113
1184
|
|
|
1114
|
-
|
|
1185
|
+
// Merge children
|
|
1186
|
+
if (!this.isChild) {
|
|
1187
|
+
this.source[1] += '\n' + this.context.programs.join('\n') + '\n';
|
|
1188
|
+
}
|
|
1115
1189
|
|
|
1116
|
-
|
|
1190
|
+
if (!this.environment.isSimple) {
|
|
1191
|
+
this.source.push("return buffer;");
|
|
1192
|
+
}
|
|
1117
1193
|
|
|
1118
|
-
|
|
1194
|
+
var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
|
|
1119
1195
|
|
|
1120
1196
|
for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
|
|
1121
1197
|
params.push("depth" + this.environment.depths.list[i]);
|
|
1122
1198
|
}
|
|
1123
1199
|
|
|
1124
|
-
if(
|
|
1200
|
+
if (asObject) {
|
|
1201
|
+
params.push(this.source.join("\n "));
|
|
1125
1202
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
container.render = fn;
|
|
1134
|
-
|
|
1135
|
-
container.children = this.environment.children;
|
|
1136
|
-
|
|
1137
|
-
return function(context, helpers, partials, data, $depth) {
|
|
1138
|
-
try {
|
|
1139
|
-
var args = Array.prototype.slice.call(arguments);
|
|
1140
|
-
args.unshift(Handlebars);
|
|
1141
|
-
return container.render.apply(container, args);
|
|
1142
|
-
} catch(e) {
|
|
1143
|
-
throw e;
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1203
|
+
return Function.apply(this, params);
|
|
1204
|
+
} else {
|
|
1205
|
+
var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + this.source.join("\n ") + '}';
|
|
1206
|
+
Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n");
|
|
1207
|
+
return functionSource;
|
|
1208
|
+
}
|
|
1146
1209
|
},
|
|
1147
1210
|
|
|
1148
1211
|
appendContent: function(content) {
|
|
@@ -1152,54 +1215,63 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1152
1215
|
append: function() {
|
|
1153
1216
|
var local = this.popStack();
|
|
1154
1217
|
this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
|
|
1218
|
+
if (this.environment.isSimple) {
|
|
1219
|
+
this.source.push("else { " + this.appendToBuffer("''") + " }");
|
|
1220
|
+
}
|
|
1155
1221
|
},
|
|
1156
1222
|
|
|
1157
1223
|
appendEscaped: function() {
|
|
1158
1224
|
var opcode = this.nextOpcode(1), extra = "";
|
|
1225
|
+
this.context.aliases.escapeExpression = 'this.escapeExpression';
|
|
1159
1226
|
|
|
1160
1227
|
if(opcode[0] === 'appendContent') {
|
|
1161
1228
|
extra = " + " + this.quotedString(opcode[1][0]);
|
|
1162
1229
|
this.eat(opcode);
|
|
1163
1230
|
}
|
|
1164
1231
|
|
|
1165
|
-
this.source.push(this.appendToBuffer("
|
|
1232
|
+
this.source.push(this.appendToBuffer("escapeExpression(" + this.popStack() + ")" + extra));
|
|
1166
1233
|
},
|
|
1167
1234
|
|
|
1168
1235
|
getContext: function(depth) {
|
|
1169
1236
|
if(this.lastContext !== depth) {
|
|
1170
1237
|
this.lastContext = depth;
|
|
1171
|
-
|
|
1172
|
-
if(depth === 0) {
|
|
1173
|
-
this.source.push("currentContext = context;");
|
|
1174
|
-
} else {
|
|
1175
|
-
this.source.push("currentContext = depth" + depth + ";");
|
|
1176
|
-
}
|
|
1177
1238
|
}
|
|
1178
1239
|
},
|
|
1179
1240
|
|
|
1180
|
-
lookupWithHelpers: function(name) {
|
|
1241
|
+
lookupWithHelpers: function(name, isScoped) {
|
|
1181
1242
|
if(name) {
|
|
1182
1243
|
var topStack = this.nextStack();
|
|
1183
1244
|
|
|
1184
|
-
|
|
1185
|
-
" = " + this.nameLookup('helpers', name, 'helper') +
|
|
1186
|
-
"; } else { " + topStack + " = " +
|
|
1187
|
-
this.nameLookup('currentContext', name, 'context') +
|
|
1188
|
-
"; }";
|
|
1245
|
+
this.usingKnownHelper = false;
|
|
1189
1246
|
|
|
1247
|
+
var toPush;
|
|
1248
|
+
if (!isScoped && this.options.knownHelpers[name]) {
|
|
1249
|
+
toPush = topStack + " = " + this.nameLookup('helpers', name, 'helper');
|
|
1250
|
+
this.usingKnownHelper = true;
|
|
1251
|
+
} else if (isScoped || this.options.knownHelpersOnly) {
|
|
1252
|
+
toPush = topStack + " = " + this.nameLookup('depth' + this.lastContext, name, 'context');
|
|
1253
|
+
} else {
|
|
1254
|
+
toPush = topStack + " = "
|
|
1255
|
+
+ this.nameLookup('helpers', name, 'helper')
|
|
1256
|
+
+ " || "
|
|
1257
|
+
+ this.nameLookup('depth' + this.lastContext, name, 'context');
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
toPush += ';';
|
|
1190
1261
|
this.source.push(toPush);
|
|
1191
1262
|
} else {
|
|
1192
|
-
this.pushStack(
|
|
1263
|
+
this.pushStack('depth' + this.lastContext);
|
|
1193
1264
|
}
|
|
1194
1265
|
},
|
|
1195
1266
|
|
|
1196
1267
|
lookup: function(name) {
|
|
1197
1268
|
var topStack = this.topStack();
|
|
1198
|
-
this.source.push(topStack + " = " +
|
|
1269
|
+
this.source.push(topStack + " = (" + topStack + " === null || " + topStack + " === undefined || " + topStack + " === false ? " +
|
|
1270
|
+
topStack + " : " + this.nameLookup(topStack, name, 'context') + ");");
|
|
1199
1271
|
},
|
|
1200
1272
|
|
|
1201
1273
|
pushStringParam: function(string) {
|
|
1202
|
-
this.pushStack(
|
|
1274
|
+
this.pushStack('depth' + this.lastContext);
|
|
1203
1275
|
this.pushString(string);
|
|
1204
1276
|
},
|
|
1205
1277
|
|
|
@@ -1211,30 +1283,47 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1211
1283
|
this.pushStack(name);
|
|
1212
1284
|
},
|
|
1213
1285
|
|
|
1214
|
-
invokeMustache: function(paramSize, original) {
|
|
1215
|
-
this.populateParams(paramSize, this.quotedString(original), "{}", null, function(nextStack, helperMissingString, id) {
|
|
1216
|
-
this.
|
|
1217
|
-
|
|
1286
|
+
invokeMustache: function(paramSize, original, hasHash) {
|
|
1287
|
+
this.populateParams(paramSize, this.quotedString(original), "{}", null, hasHash, function(nextStack, helperMissingString, id) {
|
|
1288
|
+
if (!this.usingKnownHelper) {
|
|
1289
|
+
this.context.aliases.helperMissing = 'helpers.helperMissing';
|
|
1290
|
+
this.context.aliases.undef = 'void 0';
|
|
1291
|
+
this.source.push("else if(" + id + "=== undef) { " + nextStack + " = helperMissing.call(" + helperMissingString + "); }");
|
|
1292
|
+
if (nextStack !== id) {
|
|
1293
|
+
this.source.push("else { " + nextStack + " = " + id + "; }");
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1218
1296
|
});
|
|
1219
1297
|
},
|
|
1220
1298
|
|
|
1221
|
-
invokeProgram: function(guid, paramSize) {
|
|
1299
|
+
invokeProgram: function(guid, paramSize, hasHash) {
|
|
1222
1300
|
var inverse = this.programExpression(this.inverse);
|
|
1223
1301
|
var mainProgram = this.programExpression(guid);
|
|
1224
1302
|
|
|
1225
|
-
this.populateParams(paramSize, null, mainProgram, inverse, function(nextStack, helperMissingString, id) {
|
|
1226
|
-
this.
|
|
1303
|
+
this.populateParams(paramSize, null, mainProgram, inverse, hasHash, function(nextStack, helperMissingString, id) {
|
|
1304
|
+
if (!this.usingKnownHelper) {
|
|
1305
|
+
this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
|
|
1306
|
+
this.source.push("else { " + nextStack + " = blockHelperMissing.call(" + helperMissingString + "); }");
|
|
1307
|
+
}
|
|
1227
1308
|
});
|
|
1228
1309
|
},
|
|
1229
1310
|
|
|
1230
|
-
populateParams: function(paramSize, helperId, program, inverse, fn) {
|
|
1311
|
+
populateParams: function(paramSize, helperId, program, inverse, hasHash, fn) {
|
|
1312
|
+
var needsRegister = hasHash || this.options.stringParams || inverse || this.options.data;
|
|
1231
1313
|
var id = this.popStack(), nextStack;
|
|
1232
|
-
var params = [], param, stringParam;
|
|
1314
|
+
var params = [], param, stringParam, stringOptions;
|
|
1233
1315
|
|
|
1234
|
-
|
|
1316
|
+
if (needsRegister) {
|
|
1317
|
+
this.register('tmp1', program);
|
|
1318
|
+
stringOptions = 'tmp1';
|
|
1319
|
+
} else {
|
|
1320
|
+
stringOptions = '{ hash: {} }';
|
|
1321
|
+
}
|
|
1235
1322
|
|
|
1236
|
-
|
|
1237
|
-
|
|
1323
|
+
if (needsRegister) {
|
|
1324
|
+
var hash = (hasHash ? this.popStack() : '{}');
|
|
1325
|
+
this.source.push('tmp1.hash = ' + hash + ';');
|
|
1326
|
+
}
|
|
1238
1327
|
|
|
1239
1328
|
if(this.options.stringParams) {
|
|
1240
1329
|
this.source.push('tmp1.contexts = [];');
|
|
@@ -1258,35 +1347,29 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1258
1347
|
this.source.push('tmp1.data = data;');
|
|
1259
1348
|
}
|
|
1260
1349
|
|
|
1261
|
-
params.push(
|
|
1262
|
-
|
|
1263
|
-
// TODO: This is legacy behavior. Deprecate and remove.
|
|
1264
|
-
if(inverse) {
|
|
1265
|
-
params.push(inverse);
|
|
1266
|
-
}
|
|
1350
|
+
params.push(stringOptions);
|
|
1267
1351
|
|
|
1268
1352
|
this.populateCall(params, id, helperId || id, fn);
|
|
1269
1353
|
},
|
|
1270
1354
|
|
|
1271
1355
|
populateCall: function(params, id, helperId, fn) {
|
|
1272
|
-
var paramString = ["
|
|
1273
|
-
var helperMissingString = ["
|
|
1356
|
+
var paramString = ["depth0"].concat(params).join(", ");
|
|
1357
|
+
var helperMissingString = ["depth0"].concat(helperId).concat(params).join(", ");
|
|
1274
1358
|
|
|
1275
|
-
nextStack = this.nextStack();
|
|
1359
|
+
var nextStack = this.nextStack();
|
|
1276
1360
|
|
|
1277
|
-
this.
|
|
1361
|
+
if (this.usingKnownHelper) {
|
|
1362
|
+
this.source.push(nextStack + " = " + id + ".call(" + paramString + ");");
|
|
1363
|
+
} else {
|
|
1364
|
+
this.context.aliases.functionType = '"function"';
|
|
1365
|
+
this.source.push("if(typeof " + id + " === functionType) { " + nextStack + " = " + id + ".call(" + paramString + "); }");
|
|
1366
|
+
}
|
|
1278
1367
|
fn.call(this, nextStack, helperMissingString, id);
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
invokeInverse: function(guid) {
|
|
1282
|
-
var program = this.programExpression(guid);
|
|
1283
|
-
|
|
1284
|
-
var blockMissingParams = ["context", this.topStack(), "this.noop", program];
|
|
1285
|
-
this.pushStack("helpers.blockHelperMissing.call(" + blockMissingParams.join(", ") + ")");
|
|
1368
|
+
this.usingKnownHelper = false;
|
|
1286
1369
|
},
|
|
1287
1370
|
|
|
1288
1371
|
invokePartial: function(context) {
|
|
1289
|
-
this.pushStack("
|
|
1372
|
+
this.pushStack("self.invokePartial(" + this.nameLookup('partials', context, 'partial') + ", '" + context + "', " + this.popStack() + ", helpers, partials);");
|
|
1290
1373
|
},
|
|
1291
1374
|
|
|
1292
1375
|
assignToHash: function(key) {
|
|
@@ -1302,48 +1385,38 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1302
1385
|
|
|
1303
1386
|
compileChildren: function(environment, options) {
|
|
1304
1387
|
var children = environment.children, child, compiler;
|
|
1305
|
-
var compiled = [];
|
|
1306
1388
|
|
|
1307
1389
|
for(var i=0, l=children.length; i<l; i++) {
|
|
1308
1390
|
child = children[i];
|
|
1309
1391
|
compiler = new this.compiler();
|
|
1310
1392
|
|
|
1311
|
-
|
|
1393
|
+
this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children
|
|
1394
|
+
var index = this.context.programs.length;
|
|
1395
|
+
child.index = index;
|
|
1396
|
+
child.name = 'program' + index;
|
|
1397
|
+
this.context.programs[index] = compiler.compile(child, options, this.context);
|
|
1312
1398
|
}
|
|
1313
|
-
|
|
1314
|
-
environment.rawChildren = children;
|
|
1315
|
-
environment.children = compiled;
|
|
1316
1399
|
},
|
|
1317
1400
|
|
|
1318
1401
|
programExpression: function(guid) {
|
|
1319
|
-
if(guid == null) { return "
|
|
1402
|
+
if(guid == null) { return "self.noop"; }
|
|
1320
1403
|
|
|
1321
|
-
var
|
|
1322
|
-
|
|
1323
|
-
var
|
|
1324
|
-
|
|
1325
|
-
if(this.options.data) { programParams.push("data"); }
|
|
1404
|
+
var child = this.environment.children[guid],
|
|
1405
|
+
depths = child.depths.list;
|
|
1406
|
+
var programParams = [child.index, child.name, "data"];
|
|
1326
1407
|
|
|
1327
1408
|
for(var i=0, l = depths.length; i<l; i++) {
|
|
1328
1409
|
depth = depths[i];
|
|
1329
1410
|
|
|
1330
|
-
if(depth === 1) { programParams.push("
|
|
1411
|
+
if(depth === 1) { programParams.push("depth0"); }
|
|
1331
1412
|
else { programParams.push("depth" + (depth - 1)); }
|
|
1332
1413
|
}
|
|
1333
1414
|
|
|
1334
|
-
if(!this.environment.usePartial) {
|
|
1335
|
-
if(programParams[3]) {
|
|
1336
|
-
programParams[2] = "null";
|
|
1337
|
-
} else {
|
|
1338
|
-
programParams.pop();
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
1415
|
if(depths.length === 0) {
|
|
1343
|
-
return "
|
|
1416
|
+
return "self.program(" + programParams.join(", ") + ")";
|
|
1344
1417
|
} else {
|
|
1345
|
-
programParams
|
|
1346
|
-
return "
|
|
1418
|
+
programParams.shift();
|
|
1419
|
+
return "self.programWithDepth(" + programParams.join(", ") + ")";
|
|
1347
1420
|
}
|
|
1348
1421
|
},
|
|
1349
1422
|
|
|
@@ -1353,9 +1426,9 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1353
1426
|
},
|
|
1354
1427
|
|
|
1355
1428
|
useRegister: function(name) {
|
|
1356
|
-
if(!this.registers[name]) {
|
|
1357
|
-
this.registers[name] = true;
|
|
1358
|
-
this.registers.list.push(name);
|
|
1429
|
+
if(!this.context.registers[name]) {
|
|
1430
|
+
this.context.registers[name] = true;
|
|
1431
|
+
this.context.registers.list.push(name);
|
|
1359
1432
|
}
|
|
1360
1433
|
},
|
|
1361
1434
|
|
|
@@ -1380,7 +1453,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1380
1453
|
|
|
1381
1454
|
quotedString: function(str) {
|
|
1382
1455
|
return '"' + str
|
|
1383
|
-
.replace(
|
|
1456
|
+
.replace(/\\/g, '\\\\')
|
|
1384
1457
|
.replace(/"/g, '\\"')
|
|
1385
1458
|
.replace(/\n/g, '\\n')
|
|
1386
1459
|
.replace(/\r/g, '\\r') + '"';
|
|
@@ -1388,48 +1461,111 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
|
1388
1461
|
};
|
|
1389
1462
|
|
|
1390
1463
|
var reservedWords = ("break case catch continue default delete do else finally " +
|
|
1391
|
-
"for function if in instanceof new return switch this throw " +
|
|
1392
|
-
"try typeof var void while with null true false
|
|
1464
|
+
"for function if in instanceof new return switch this throw " +
|
|
1465
|
+
"try typeof var void while with null true false").split(" ");
|
|
1393
1466
|
|
|
1394
|
-
compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
|
|
1467
|
+
var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
|
|
1395
1468
|
|
|
1396
1469
|
for(var i=0, l=reservedWords.length; i<l; i++) {
|
|
1397
1470
|
compilerWords[reservedWords[i]] = true;
|
|
1398
1471
|
}
|
|
1399
1472
|
|
|
1473
|
+
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
|
|
1474
|
+
if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) {
|
|
1475
|
+
return true;
|
|
1476
|
+
}
|
|
1477
|
+
return false;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1400
1480
|
})(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
|
|
1401
1481
|
|
|
1482
|
+
Handlebars.precompile = function(string, options) {
|
|
1483
|
+
options = options || {};
|
|
1484
|
+
|
|
1485
|
+
var ast = Handlebars.parse(string);
|
|
1486
|
+
var environment = new Handlebars.Compiler().compile(ast, options);
|
|
1487
|
+
return new Handlebars.JavaScriptCompiler().compile(environment, options);
|
|
1488
|
+
};
|
|
1489
|
+
|
|
1490
|
+
Handlebars.compile = function(string, options) {
|
|
1491
|
+
options = options || {};
|
|
1492
|
+
|
|
1493
|
+
var compiled;
|
|
1494
|
+
function compile() {
|
|
1495
|
+
var ast = Handlebars.parse(string);
|
|
1496
|
+
var environment = new Handlebars.Compiler().compile(ast, options);
|
|
1497
|
+
var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
|
|
1498
|
+
return Handlebars.template(templateSpec);
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
// Template is only compiled on first use and cached after that point.
|
|
1502
|
+
return function(context, options) {
|
|
1503
|
+
if (!compiled) {
|
|
1504
|
+
compiled = compile();
|
|
1505
|
+
}
|
|
1506
|
+
return compiled.call(this, context, options);
|
|
1507
|
+
};
|
|
1508
|
+
};
|
|
1509
|
+
;
|
|
1510
|
+
// lib/handlebars/vm.js
|
|
1402
1511
|
Handlebars.VM = {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1512
|
+
template: function(templateSpec) {
|
|
1513
|
+
// Just add water
|
|
1514
|
+
var container = {
|
|
1515
|
+
escapeExpression: Handlebars.Utils.escapeExpression,
|
|
1516
|
+
invokePartial: Handlebars.VM.invokePartial,
|
|
1517
|
+
programs: [],
|
|
1518
|
+
program: function(i, fn, data) {
|
|
1519
|
+
var programWrapper = this.programs[i];
|
|
1520
|
+
if(data) {
|
|
1521
|
+
return Handlebars.VM.program(fn, data);
|
|
1522
|
+
} else if(programWrapper) {
|
|
1523
|
+
return programWrapper;
|
|
1524
|
+
} else {
|
|
1525
|
+
programWrapper = this.programs[i] = Handlebars.VM.program(fn);
|
|
1526
|
+
return programWrapper;
|
|
1527
|
+
}
|
|
1528
|
+
},
|
|
1529
|
+
programWithDepth: Handlebars.VM.programWithDepth,
|
|
1530
|
+
noop: Handlebars.VM.noop
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
return function(context, options) {
|
|
1534
|
+
options = options || {};
|
|
1535
|
+
return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
|
|
1410
1536
|
};
|
|
1411
1537
|
},
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1538
|
+
|
|
1539
|
+
programWithDepth: function(fn, data, $depth) {
|
|
1540
|
+
var args = Array.prototype.slice.call(arguments, 2);
|
|
1541
|
+
|
|
1542
|
+
return function(context, options) {
|
|
1543
|
+
options = options || {};
|
|
1544
|
+
|
|
1545
|
+
return fn.apply(this, [context, options.data || data].concat(args));
|
|
1415
1546
|
};
|
|
1416
1547
|
},
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1548
|
+
program: function(fn, data) {
|
|
1549
|
+
return function(context, options) {
|
|
1550
|
+
options = options || {};
|
|
1551
|
+
|
|
1552
|
+
return fn(context, options.data || data);
|
|
1553
|
+
};
|
|
1422
1554
|
},
|
|
1555
|
+
noop: function() { return ""; },
|
|
1423
1556
|
invokePartial: function(partial, name, context, helpers, partials) {
|
|
1424
1557
|
if(partial === undefined) {
|
|
1425
1558
|
throw new Handlebars.Exception("The partial " + name + " could not be found");
|
|
1426
1559
|
} else if(partial instanceof Function) {
|
|
1427
|
-
return partial(context, helpers, partials);
|
|
1560
|
+
return partial(context, {helpers: helpers, partials: partials});
|
|
1561
|
+
} else if (!Handlebars.compile) {
|
|
1562
|
+
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in vm mode");
|
|
1428
1563
|
} else {
|
|
1429
|
-
partials[name] = Handlebars.
|
|
1430
|
-
return partials[name](context, helpers, partials);
|
|
1564
|
+
partials[name] = Handlebars.compile(partial);
|
|
1565
|
+
return partials[name](context, {helpers: helpers, partials: partials});
|
|
1431
1566
|
}
|
|
1432
1567
|
}
|
|
1433
1568
|
};
|
|
1434
1569
|
|
|
1435
|
-
Handlebars.
|
|
1570
|
+
Handlebars.template = Handlebars.VM.template;
|
|
1571
|
+
;
|