- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 ember js 中构建一个应用程序,以 Rails 作为后端(我正在使用 ember-rails gem),并且我正在努力寻找正确的方法来命名我的 Handlebars 模板。正确的约定是什么?例如:
我想对于路线 /user_profiles/4/
我应该将我的模板放在 user_profiles/show.hbs
中,对吗?或者应该是userProfile/show.hbs
?
对于一个简单的模板来说也是如此,它应该是 user_menu.hbs
还是 userMenu.hbs
(它们都适合我)。然而,为了用助手渲染它,我需要这样做:
{{render 'userMenu' }}
正确使用我的App.UserMenuController
那么我应该在任何地方都使用camelCase还是snake_case?或两者(文件夹名采用驼峰命名法,文件名采用蛇形命名法)
有人可以帮助我理解它,因为在 ember 指南中,大多数都是简单的名称,如 posts
或 comments
,所以很难理解。
最佳答案
I'm struggling with the correct way to name my handlebars templates. What is the correct convention?
大多数情况下,模板名称将与路由名称匹配。如果路由名称有 .
将其替换为 /
和隐蔽camelCase
将名称路由至 under_scored
模板名称。请参阅the naming conventions guide了解更多示例。
I imagine that for the route /user_profiles/4/ I should put my template in user_profiles/show.hbs right? Or should it be userProfile/show.hbs?
不确定您从哪里得到show.hbs
。由于模板基于路由名称(而不是 url),因此无法区分。假设您有这样的路线:
App.Router.map(function() {
this.route('user_profile', { path: '/user_profiles/:user_profile_id' });
});
路由名称是“user_profile”,因此 Ember.js 将查找这些对象:
App.UserProfileRoute
App.UserProfileController
user_profile
模板或者,您可以使用路线名称 userProfile
,其他一切都保持不变。
So Should I use camelCase every where or snake_case ?? or both (camelCase for folders and snake_case for filenames)
约定似乎是camelCase
对于除模板路径(以及模板的文件夹名/文件名)之外的所有内容
关于ember.js - Ember js 中的正确模板名称约定:camelCase 与 Snake_case,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15367744/
我有一些数据清理任务。我有一个专栏,从 H6 开始,然后从他们开始。该列包含本应在 snake_case 中的数据,但事实并非如此。单元格值的形式为: 使用驼峰式大小写:“CamelCase” 带空格
我正在尝试将多维数组的键从 CamelCase 转换为 snake_case,增加了复杂性,有些键有一个我想删除的感叹号。 例如: $array = array( '!AccountNumber'
我正在使用我的 pylintrc 文件创建一个简单的项目,并在测试方法中遇到此错误: method name - test_calculator_add_method_returns_correct_
假设我们有一些具有驼峰式属性的对象类型: type Foo = { propertyBob: string; propertyJane?: number; } 有没有什么方法可以创建一个将 c
我正在将一个 JSON 对象从 PUT 请求传递到我的服务器。请求本身有效,但是 JSON 中带有下划线 (snake_case) 的字段似乎被忽略了。请求输出接收到的数据,看看结果如何,带有下划线的
需要以下查询的结果 select regexp_replace('StackOverflow', 'something', 'something') 作为 stack_overflow 最佳答案 以下
如果我有: $string = "PascalCase"; 我需要 "pascal_case" PHP 是否为此提供了函数? 最佳答案 一个更短的解决方案:类似于编辑器的一个简化的正则表达式并修复“尾
我正在尝试使用 Notepad++ 宏进行一些文本操作。我的最后一步是将 camelCase 字符串转换为 SNAKE_CASE。到目前为止还没有运气。我对正则表达式不是很熟悉,所以无法编写自己的解决
我将以下结构发送到端点: struct IdleAlarmRequest: Encodable { let idleAlarm: [IdleAlarmParameters] enum
我有以下 JSON 对象,要使用 JSONDecoder 将其转换为对象: { "first_key": 3, "image_1000x1000": "location" } 这映射到以下 S
如何使用 Golang 和 Viper 库对 snake_case 字段进行 viper.unmarshal(&c): CryptoId string `json:"crypto_id"` 目前我得到
如何将 PascalCase 字符串转换为 underscore_case/snake_case 字符串?我还需要将点转换为下划线。 例如。转换 TypeOfData.AlphaBeta 进入 typ
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题吗? 更新问题,以便 editing this post 提供事实和引用来回答它. 关闭 3 年前。 Improve
我必须使用一个 json api,其中有一个蛇形情况下的离散字符串值列表。 下面的例子有效,但我想删除手册 fooDecoder赞成(当前已注释掉)ConfiguredJsonCodec 注释。 或者
根据这个pylint-wiki ,看来2个字母的变量名就可以了: Variable variable-rgx [a-z_][a-z0-9_]{2,30}$ 但由于某种原因,我收到以下错误: Varia
我尝试将 Jackson 配置为在使用 Micronaut 时使用 SNAKE_CASE 接受 JSON,但是,它无法识别属性 jackson.property-naming-strategy: SN
根据这个pylint-wiki ,看来2个字母的变量名就可以了: Variable variable-rgx [a-z_][a-z0-9_]{2,30}$ 但由于某种原因,我收到以下错误: Varia
由于商店是文件,所以我倾向于将它们制作成 snake_case.js,这样它们就变成了 Vue 中的 snake_case。 但是,蛇形大小写在 Vue 中似乎用得不多,因此文件应该改为 camelC
我正在做一个小项目,我们有一个基于 Express.js 的 Node 应用程序正在运行,它发送一个 json 响应,该响应具有 snake_case 格式的键。我们有另一个使用此服务的 Node 应
我正在为一个新的 web api 项目做一些工作,我的方法/参数遵循标准的 c# 命名格式;方法名是PascalCase,参数是camelCase。 不幸的是,我刚刚发现发布给客户的文档中所有参数都是
我是一名优秀的程序员,十分优秀!