嵌入一个spark变量来组成一个字符串
你好,spark 新手,所以这应该很简单。
我正在使用 Spark 将旧的 webfoms 页面转换为 mvc。 我想使用 Base.Application 来组成 url
原始标记
<img alt="" src="<%= Base.ApplicationPath %>images/screenshots/myImage.jpg" />
的 src我已经在 Spark 中尝试过了,
<img alt= src=${ Base.ApplicationPath }+">images/screenshots/myImage.jpg" />
但没有任何乐趣。
我如何在火花中做到这一点?
Hi new to spark so this should be simple.
I'm converting an old webfoms page to mvc using spark.
I want to use the Base.Application to make up the src of a url
original markup
<img alt="" src="<%= Base.ApplicationPath %>images/screenshots/myImage.jpg" />
I've tried this in spark
<img alt= src=${ Base.ApplicationPath }+">images/screenshots/myImage.jpg" />
but no joy.
How do i do this in spark?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您是否意识到这一点,但 Spark 有一个 DefaultResourcePathManager,如果您在资源中添加波浪号前缀,它会自动定位站点根目录,因此这应该可以正常工作,并且看起来更整洁。
使用这种技术还有一个额外的好处......抓住你的短裤!在不改变您的视图的情况下,只需确保使用波形符约定,您就可以动态地将静态资源的请求重定向到内容分发网络 (CDN) 或完全不同的位置 - 甚至是您编译的 Spark Module .dll 内的嵌入式资源用于部署中的 dll 删除。
例如,要将其连接到 CDN,您所需要做的就是将以下类型的内容添加到您的 Spark 设置中:
...从那时起,这些资源将从新位置获取。这对于本地场景测试以及稍后部署到云非常有用。
Not sure if you're aware of this, but Spark has a DefaultResourcePathManager that will automatically locate the Site Root if you prefix the resource with a tilde, so this should work just fine, and looks neater.
There's an added bonus to using this technique as well....hold on to your shorts! Without changing your view, simply by making sure you use the tilde convention, you can dynamically redirect requests for your static resources to a content delivery network (CDN) or a completely different location - even an embedded resource inside a Spark Module .dll you compile for dll drop in deployment.
For example, to hook it up to a CDN, all you'll need to do is add the following kind of thing to your Spark Settings:
...and from then on those resources will be fetched from the new location instead. This is great for scenario testing locally, and the deploying to the cloud later.
对语法的轻微调整已经对其进行了排序。
Slight tweak of the syntax has sorted it.