简体   繁体   English

多个文件扩展名有什么影响?

[英]What effects do multiple file extensions have?

I use Ruby on Rails and Uglify, which allows me to code in Coffeescript. 我使用Ruby on Rails和Uglify,这使我可以在Coffeescript中进行编码。 So both of these file extensions are valid: 因此,这两个文件扩展名均有效:

#1 file.coffee
#2 file.js.coffee

Would I be creating potential problems for myself by only using style #1? 我会只使用样式#1为自己创造潜在的问题吗? Is the .js necessary at any point from compiling to running on, for example, Heroku (or some other web server)? 从编译到在Heroku(或其他Web服务器)上运行,在任何时候都需要.js吗?

I believe I read somewhere that Rails only looks at the last file extension and treats it accordingly. 我相信我读过某个地方,Rails仅查看最后一个文件扩展名,并相应地对其进行处理。 But I am wondering if there are any drawbacks to anything by not including .js . 但是我想知道是否不包含.js对任何东西都有任何缺点。

Ultimately, what is the effect of multiple file extensions? 最终,多个文件扩展名的作用是什么?

This convention is usually followed for Rails templates. Rails模板通常遵循此约定。 Other examples are .html.erb and .html.haml . 其他示例是.html.erb.html.haml This conforms to the format .[format].[builder] . 这符合格式.[format].[builder] What you will notice is that these files will have a mixture of code. 您会注意到,这些文件将混合使用代码。 For instance, .js.coffee would have both Javascript and Coffeescript. 例如, .js.coffee将同时具有Javascript和Coffeescript。

But ultimately, the [format] part of it is used to find the appropriate template to use and the [builder] part denotes which template processor to use. 但最终,它的[format]部分用于查找要使用的适当模板,而[builder]部分指示要使用的模板处理器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM