templates: Rename *.handlebars ↦ *.hbs and - ↦ _.

Tweaked by tabbott to avoid accidentally disabling the linter for
handlebars templates.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-07-11 15:52:56 -07:00 committed by Tim Abbott
parent 107da5402c
commit 3c3471b720
184 changed files with 152 additions and 152 deletions

View File

@ -236,7 +236,7 @@ functions or other arguments following them.
Combine adjacent on-ready functions, if they are logically related.
The best way to build complicated DOM elements is a Mustache template
like `static/templates/message_reactions.handlebars`. For simpler things
like `static/templates/message_reactions.hbs`. For simpler things
you can use jQuery DOM building APIs like so:
var new_tr = $('<tr />').attr('id', object.id);

View File

@ -64,7 +64,7 @@ templates.
In order to find the context definition, you should grep without using
the file extension. For example, to find where
`invite_subscription.handlebars` is rendered, you should run something
`invite_subscription.hbs` is rendered, you should run something
like this:
```

View File

@ -42,7 +42,7 @@ organization in Zulip). The following files are involved in the process:
consistent and correct.
**Frontend**
- `static/templates/settings/organization-permissions-admin.handlebars`: defines
- `static/templates/settings/organization_permissions_admin.hbs`: defines
the structure of the admin permissions page (checkboxes for each organization
permission setting).
- `static/js/settings_org.js`: handles organization setting form submission.
@ -488,7 +488,7 @@ handled on the client.
To add the checkbox to the admin page, modify the relevant template in
`static/templates/settings/`, which can be
`organization-permissions-admin.handlebars` or `organization-settings-admin.handlebars`
`organization_permissions_admin.hbs` or `organization_settings_admin.hbs`
(omitted here since it is relatively straightforward).
Then add the new form control in `static/js/admin.js`.

View File

@ -1086,7 +1086,7 @@ run_test('on_events', () => {
var called;
templates.render = function (template_name, context) {
called = true;
assert.equal(template_name, 'compose-invite-users');
assert.equal(template_name, 'compose_invite_users');
assert.equal(context.email, 'foo@bar.com');
assert.equal(context.name, 'Foo Barson');
return 'fake-compose-invite-user-template';

View File

@ -36,7 +36,7 @@ const _channel = {};
const _templates = {
render: function (name, data) {
if (name === 'settings/admin-realm-domains-list') {
if (name === 'settings/admin_realm_domains_list') {
assert(data.realm_domain.domain);
return 'stub-domains-list';
}

View File

@ -11,7 +11,7 @@ const { window } = new JSDOM();
global.$ = require('jquery')(window);
// When writing these tests, the following command might be helpful:
// ./tools/get-handlebar-vars static/templates/*.handlebars
// ./tools/get-handlebar-vars static/templates/*.hbs
function render(template_name, args) {
return global.render_template(template_name, args);
@ -20,13 +20,13 @@ function render(template_name, args) {
run_test('finding_partials', () => {
var fns = global.find_included_partials('settings_tab');
assert.deepEqual(fns, [
'settings/account-settings',
'settings/display-settings',
'settings/notification-settings',
'settings/bot-settings',
'settings/alert-word-settings',
'settings/attachments-settings',
'settings/muted-topics-settings',
'settings/account_settings',
'settings/display_settings',
'settings/notification_settings',
'settings/bot_settings',
'settings/alert_word_settings',
'settings/attachments_settings',
'settings/muted_topics_settings',
]);
});
@ -91,7 +91,7 @@ run_test('admin_realm_domains_list', () => {
allow_subdomains: true,
},
};
html += render("settings/admin-realm-domains-list", args);
html += render("settings/admin_realm_domains_list", args);
html += "</table>";
var button = $(html).find('.button');
@ -115,7 +115,7 @@ run_test('admin_realm_dropdown_stream_list', () => {
stream_id: 18,
},
};
html += render("settings/admin-realm-dropdown-stream-list", args);
html += render("settings/admin_realm_dropdown_stream_list", args);
html += "</ul>";
var link = $(html).find("a");
@ -519,12 +519,12 @@ run_test('compose_invite_users', () => {
name: 'Hamlet',
can_subscribe_other_users: true,
};
var html = render('compose-invite-users', args);
var html = render('compose_invite_users', args);
var button = $(html).find("button").first();
assert.equal(button.text(), "translated: Subscribe");
args.can_subscribe_other_users = false;
html = render('compose-invite-users', args);
html = render('compose_invite_users', args);
button = $(html).find("button").first();
assert.equal(button.length, 0);
});
@ -590,7 +590,7 @@ run_test('compose_private_stream_alert', () => {
run_test('custom_user_profile_field', () => {
var field = {name: "GitHub user name", id: 2, hint: "Or link to profile"};
var args = {field: field, field_value: {value: "@GitHub", rendered_value: "<p>@GitHub</p>"}, field_type: "text"};
var html = render('settings/custom-user-profile-field', args);
var html = render('settings/custom_user_profile_field', args);
assert.equal($(html).attr('data-field-id'), 2);
assert.equal($(html).find('.custom_user_field_value').val(), "@GitHub");
assert.equal($(html).find('.field_hint').text(), "Or link to profile");
@ -602,7 +602,7 @@ run_test('deactivate_stream_modal', () => {
stream_name: "Public stream",
stream_id: 1,
};
var html = render('settings/deactivation-stream-modal', args);
var html = render('settings/deactivation_stream_modal', args);
var modal_header = $(html).find("#deactivation_stream_modal_label");
assert.equal(modal_header.text(), "translated: Delete stream " + args.stream_name);
@ -1097,7 +1097,7 @@ run_test('revoke_invite_modal', () => {
};
var html = "<div>";
html += render('settings/revoke-invite-modal', args);
html += render('settings/revoke_invite_modal', args);
html += "</div>";
assert.equal($(html).find("p strong").text(), "iago@zulip.com");
});
@ -1471,7 +1471,7 @@ run_test('upload_space_stats', () => {
percent_used: 50,
upload_quota: "1 GB",
};
var html = render('settings/upload-space-stats', args);
var html = render('settings/upload_space_stats', args);
assert.equal($(html).text().trim(), "translated: Organization using 50% of 1 GB.\n translated: Upgrade for more space.");
args = {
@ -1479,7 +1479,7 @@ run_test('upload_space_stats', () => {
percent_used: 10,
upload_quota: "5 GB",
};
html = render('settings/upload-space-stats', args);
html = render('settings/upload_space_stats', args);
assert.equal($(html).text().trim(), "translated: Organization using 10% of 5 GB.");
});
@ -1678,7 +1678,7 @@ run_test('edit_outgoing_webhook_service', () => {
service: {base_url: "http://www.foo.bar",
interface: "1"},
};
var html = render('settings/edit-outgoing-webhook-service', args);
var html = render('settings/edit_outgoing_webhook_service', args);
assert.equal($(html).find('#edit_service_base_url').val(), args.service.base_url);
assert.equal($(html).find('#edit_service_interface').val(), args.service.interface);
});
@ -1688,7 +1688,7 @@ run_test('edit_embedded_bot_service', () => {
service: {service_name: "giphy",
config_data: {key: "abcd1234"}},
};
var html = render('settings/edit-embedded-bot-service', args);
var html = render('settings/edit_embedded_bot_service', args);
assert.equal($(html).find('#embedded_bot_key_edit').attr('name'), 'key');
assert.equal($(html).find('#embedded_bot_key_edit').val(), 'abcd1234');
});

View File

@ -141,11 +141,11 @@ run_test('poll_data_holder my question', () => {
run_test('activate another person poll', () => {
people.is_my_user_id = return_false;
templates.render = (template_name) => {
if (template_name === 'widgets/poll-widget') {
return 'widgets/poll-widget';
if (template_name === 'widgets/poll_widget') {
return 'widgets/poll_widget';
}
if (template_name === 'widgets/poll-widget-results') {
return 'widgets/poll-widget-results';
if (template_name === 'widgets/poll_widget_results') {
return 'widgets/poll_widget_results';
}
};
@ -234,8 +234,8 @@ run_test('activate another person poll', () => {
poll_widget.activate(opts);
assert.equal(widget_elem.html(), 'widgets/poll-widget');
assert.equal(widget_option_container.html(), 'widgets/poll-widget-results');
assert.equal(widget_elem.html(), 'widgets/poll_widget');
assert.equal(widget_option_container.html(), 'widgets/poll_widget_results');
assert.equal(poll_question_header.text(), 'What do you want?');
const e = {
@ -306,11 +306,11 @@ run_test('activate own poll', () => {
people.is_my_user_id = return_true;
templates.render = (template_name) => {
if (template_name === 'widgets/poll-widget') {
return 'widgets/poll-widget';
if (template_name === 'widgets/poll_widget') {
return 'widgets/poll_widget';
}
if (template_name === 'widgets/poll-widget-results') {
return 'widgets/poll-widget-results';
if (template_name === 'widgets/poll_widget_results') {
return 'widgets/poll_widget_results';
}
};
@ -396,8 +396,8 @@ run_test('activate own poll', () => {
poll_widget.activate(opts);
assert.equal(widget_elem.html(), 'widgets/poll-widget');
assert.equal(widget_option_container.html(), 'widgets/poll-widget-results');
assert.equal(widget_elem.html(), 'widgets/poll_widget');
assert.equal(widget_option_container.html(), 'widgets/poll_widget_results');
assert.equal(poll_question_header.text(), 'Where to go?');
{

View File

@ -68,7 +68,7 @@ exports.template_finder = (function () {
// This class lets you find template files in our file system.
// It may be slightly overkill for our flat directory system;
// it might make more sense to just do something more like
// this: get_template_dir() + name + '.handlebars'
// this: get_template_dir() + name + '.hbs'
var self = {};
@ -76,12 +76,12 @@ exports.template_finder = (function () {
var all_files = exports.walk(template_dir());
var files = all_files
.filter(function (file) {
return (/\.handlebars$/).test(file.name);
return (/\.hbs$/).test(file.name);
})
.map(function (file) {
return {
url: file.url,
name: file.name.replace(/\.handlebars$/, ""),
name: file.name.replace(/\.hbs$/, ""),
};
});

View File

@ -38,7 +38,7 @@ function set_upload_space_stats() {
percent_used: exports.percentage_used_space(upload_space_used),
upload_quota: attachments_ui.bytes_to_size(page_params.realm_upload_quota, true),
};
var rendered_upload_stats_html = templates.render("settings/upload-space-stats", args);
var rendered_upload_stats_html = templates.render("settings/upload_space_stats", args);
$("#attachment-stats-holder").html(rendered_upload_stats_html);
}

View File

@ -835,7 +835,7 @@ exports.initialize = function () {
name: data.mentioned.full_name,
can_subscribe_other_users: page_params.can_subscribe_other_users,
};
var new_row = templates.render("compose-invite-users", context);
var new_row = templates.render("compose_invite_users", context);
error_area.append(new_row);
}

View File

@ -285,7 +285,7 @@ exports.activate = function (opts) {
}
function build_widget() {
var html = templates.render('widgets/poll-widget');
var html = templates.render('widgets/poll_widget');
elem.html(html);
elem.find('input.poll-question').on('keyup', function (e) {
@ -346,7 +346,7 @@ exports.activate = function (opts) {
function render_results() {
var widget_data = poll_data.get_widget_data();
var html = templates.render('widgets/poll-widget-results', widget_data);
var html = templates.render('widgets/poll_widget_results', widget_data);
elem.find('ul.poll-widget').html(html);
elem.find("button.poll-vote").off('click').on('click', function (e) {

View File

@ -110,7 +110,7 @@ exports.append_custom_profile_fields = function (element_id, user_id) {
}
}
var html = templates.render("settings/custom-user-profile-field", {
var html = templates.render("settings/custom_user_profile_field", {
field: field,
field_type: all_field_template_types[field.type],
field_value: field_value,

View File

@ -401,12 +401,12 @@ exports.set_up = function () {
$("#settings_page .edit_bot .edit-bot-owner select").val(bot.owner);
var service = bot_data.get_services(bot_id)[0];
if (bot.bot_type.toString() === OUTGOING_WEBHOOK_BOT_TYPE) {
$("#service_data").append(templates.render("settings/edit-outgoing-webhook-service",
$("#service_data").append(templates.render("settings/edit_outgoing_webhook_service",
{service: service}));
$("#edit_service_interface").val(service.interface);
}
if (bot.bot_type.toString() === EMBEDDED_BOT_TYPE) {
$("#service_data").append(templates.render("settings/edit-embedded-bot-service",
$("#service_data").append(templates.render("settings/edit_embedded_bot_service",
{service: service}));
}

View File

@ -34,7 +34,7 @@ function can_admin_emoji(emoji) {
}
exports.update_custom_emoji_ui = function () {
var rendered_tip = templates.render("settings/emoji-settings-tip", {
var rendered_tip = templates.render("settings/emoji_settings_tip", {
realm_add_emoji_by_admins_only: page_params.realm_add_emoji_by_admins_only,
});
$('#emoji-settings').find('.emoji-settings-tip-container').html(rendered_tip);

View File

@ -146,7 +146,7 @@ exports.on_load_success = function (invites_data, initialize_event_handlers) {
meta.invite_id = $(e.currentTarget).attr("data-invite-id");
meta.is_multiuse = $(e.currentTarget).attr("data-is-multiuse");
var ctx = {is_multiuse: meta.is_multiuse === "true", email: email, referred_by: referred_by};
var rendered_revoke_modal = templates.render("settings/revoke-invite-modal", ctx);
var rendered_revoke_modal = templates.render("settings/revoke_invite_modal", ctx);
$("#revoke_invite_modal_holder").html(rendered_revoke_modal);
$("#revoke_invite_modal #do_revoke_invite_button").attr("data-invite-id", meta.invite_id);
$("#revoke_invite_modal #do_revoke_invite_button").attr("data-is-multiuse", meta.is_multiuse);

View File

@ -325,7 +325,7 @@ exports.populate_realm_domains = function (realm_domains) {
var realm_domains_table_body = $("#realm_domains_table tbody").expectOne();
realm_domains_table_body.find("tr").remove();
_.each(realm_domains, function (realm_domain) {
realm_domains_table_body.append(templates.render("settings/admin-realm-domains-list", {realm_domain: realm_domain}));
realm_domains_table_body.append(templates.render("settings/admin_realm_domains_list", {realm_domain: realm_domain}));
});
};
function sort_object_by_key(obj) {
@ -357,7 +357,7 @@ function insert_tip_box() {
if (page_params.is_admin) {
return;
}
var tip_box = templates.render("settings/organization-settings-tip", {is_admin: page_params.is_admin});
var tip_box = templates.render("settings/organization_settings_tip", {is_admin: page_params.is_admin});
$(".organization-box").find(".settings-section:not(.can-edit)")
.not("#emoji-settings")
.not("#user-groups-admin")
@ -388,7 +388,7 @@ exports.populate_notifications_stream_dropdown = function (stream_list) {
list_render.create(dropdown_list_body, stream_list, {
name: "admin-realm-notifications-stream-dropdown-list",
modifier: function (item) {
return templates.render("settings/admin-realm-dropdown-stream-list", { stream: item });
return templates.render("settings/admin_realm_dropdown_stream_list", { stream: item });
},
filter: {
element: search_input,
@ -417,7 +417,7 @@ exports.populate_signup_notifications_stream_dropdown = function (stream_list) {
list_render.create(dropdown_list_body, stream_list, {
name: "admin-realm-signup-notifications-stream-dropdown-list",
modifier: function (item) {
return templates.render("settings/admin-realm-dropdown-stream-list", { stream: item });
return templates.render("settings/admin_realm_dropdown_stream_list", { stream: item });
},
filter: {
element: search_input,

View File

@ -101,7 +101,7 @@ function update_choice_delete_btn(container, display_flag) {
function create_choice_row(container) {
var context = {};
var row = templates.render("settings/profile-field-choice", context);
var row = templates.render("settings/profile_field_choice", context);
$(container).append(row);
}
@ -221,7 +221,7 @@ function set_up_choices_field_edit_form(profile_field, field_data) {
_.each(choices_data, function (choice) {
choice_list.append(
templates.render("settings/profile-field-choice", {
templates.render("settings/profile_field_choice", {
text: choice.text,
})
);

View File

@ -244,7 +244,7 @@ exports.set_up = function () {
};
function open_user_info_form_modal(person) {
var html = templates.render('user-info-form-modal', {
var html = templates.render('user_info_form_modal', {
user_id: person.user_id,
email: person.email,
full_name: people.get_full_name(person.user_id),

View File

@ -617,7 +617,7 @@ exports.initialize = function () {
return;
}
var stream_name = stream_data.maybe_get_stream_name(stream_id);
var deactivate_stream_modal = templates.render("settings/deactivation-stream-modal", {
var deactivate_stream_modal = templates.render("settings/deactivation_stream_modal", {
stream_name: stream_name,
stream_id: stream_id,
});

View File

@ -318,7 +318,7 @@ exports.register_stream_handlers = function () {
e.preventDefault();
e.stopPropagation();
$(".left-sidebar-modal-holder").empty();
$(".left-sidebar-modal-holder").html(templates.render("unstar-messages-modal"));
$(".left-sidebar-modal-holder").html(templates.render("unstar_messages_modal"));
$("#unstar-messages-modal").modal("show");
});

View File

@ -5,10 +5,10 @@ var exports = {};
exports.render = function (name, arg) {
var template;
try {
template = require('../templates/' + name + '.handlebars');
template = require('../templates/' + name + '.hbs');
} catch (_e) {
throw new Error('Cannot find template static/templates/' + name
+ '.handlebars.');
+ '.hbs.');
}
return template(arg);

View File

@ -127,7 +127,7 @@ exports.activate = function (opts) {
function render() {
var widget_data = tictactoe_data.get_widget_data();
var html = templates.render('widgets/tictactoe-widget', widget_data);
var html = templates.render('widgets/tictactoe_widget', widget_data);
elem.html(html);
elem.find("button.tictactoe-square").on('click', function (e) {

View File

@ -122,7 +122,7 @@ exports.activate = function (opts) {
var task_data = exports.task_data_holder();
function render() {
var html = templates.render('widgets/todo-widget');
var html = templates.render('widgets/todo_widget');
elem.html(html);
elem.find("button.add-task").on('click', function (e) {
@ -149,7 +149,7 @@ exports.activate = function (opts) {
function render_results() {
var widget_data = task_data.get_widget_data();
var html = templates.render('widgets/todo-widget-tasks', widget_data);
var html = templates.render('widgets/todo_widget_tasks', widget_data);
elem.find('ul.todo-widget').html(html);
elem.find(".widget-error").text('');

View File

@ -64,7 +64,7 @@ exports.activate = function (opts) {
choice.idx = idx;
});
var html = templates.render('widgets/zform-choices', data);
var html = templates.render('widgets/zform_choices', data);
var elem = $(html);
elem.find('button').on('click', function (e) {

View File

@ -1,9 +0,0 @@
{{ partial "settings/deactivation-user-modal" }}
{{ partial "settings/realm-domains-modal" }}
{{ partial "settings/revoke-invite-modal" }}
{{ partial "settings/resend-invite-modal" }}
<div id="user-info-form-modal-container"></div>

View File

@ -42,7 +42,7 @@
<hr />
<div class="edit_profile_field_choices_container">
{{#each choices}}
{{partial "settings/profile-field-choice" }}
{{partial "settings/profile_field_choice" }}
{{/each}}
</div>
</div>

View File

@ -0,0 +1,9 @@
{{ partial "settings/deactivation_user_modal" }}
{{ partial "settings/realm_domains_modal" }}
{{ partial "settings/revoke_invite_modal" }}
{{ partial "settings/resend_invite_modal" }}
<div id="user-info-form-modal-container"></div>

View File

@ -1,30 +0,0 @@
<div class="alert" id="organization-status"></div>
<div id="revoke_invite_modal_holder"></div>
{{ partial "admin-settings-modals"}}
{{ partial "settings/organization-profile-admin" }}
{{ partial "settings/organization-settings-admin" }}
{{ partial "settings/organization-permissions-admin" }}
{{ partial "settings/emoji-settings-admin" }}
{{ partial "settings/user-list-admin" }}
{{ partial "settings/deactivated-users-admin" }}
{{ partial "settings/bot-list-admin" }}
{{ partial "settings/default-streams-list-admin" }}
{{ partial "settings/auth-methods-settings-admin" }}
{{ partial "settings/linkifier-settings-admin" }}
{{ partial "settings/invites-list-admin" }}
{{ partial "user-groups-admin" }}
{{ partial "settings/profile-field-settings-admin" }}

View File

@ -0,0 +1,30 @@
<div class="alert" id="organization-status"></div>
<div id="revoke_invite_modal_holder"></div>
{{ partial "admin_settings_modals"}}
{{ partial "settings/organization_profile_admin" }}
{{ partial "settings/organization_settings_admin" }}
{{ partial "settings/organization_permissions_admin" }}
{{ partial "settings/emoji_settings_admin" }}
{{ partial "settings/user_list_admin" }}
{{ partial "settings/deactivated_users_admin" }}
{{ partial "settings/bot_list_admin" }}
{{ partial "settings/default_streams_list_admin" }}
{{ partial "settings/auth_methods_settings_admin" }}
{{ partial "settings/linkifier_settings_admin" }}
{{ partial "settings/invites_list_admin" }}
{{ partial "user_groups_admin" }}
{{ partial "settings/profile_field_settings_admin" }}

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -3,7 +3,7 @@
<div id="org-auth_settings" class="admin-table-wrapper org-subsection-parent">
<div class ="subsection-header">
<h3>{{t "Authentication methods" }}</h3>
{{ partial "settings/settings-save-discard-widget" "section_name" "auth_settings" }}
{{ partial "settings/settings_save_discard_widget" "section_name" "auth_settings" }}
</div>
<div>

Some files were not shown because too many files have changed in this diff Show More