所以我想用webpack做一个非常简单的任务.
我有一些静态HTML模板,例如
的test.html
<div><span>template content</span></div>
Run Code Online (Sandbox Code Playgroud)
而我想要做的就是在模板中返回字符串,例如
require("raw!./test.html")
Run Code Online (Sandbox Code Playgroud)
应该返回一个字符串,如:
"<div><span>template content</span></div>"
Run Code Online (Sandbox Code Playgroud)
但相反,它返回以下字符串
"modules.exports = <div><span>template content</span></div>"
Run Code Online (Sandbox Code Playgroud)
我尝试了几个模块,比如raw-loader和html-loader.并且它们都表现出相同的方式.所以我看了一下源代码,只是为了发现它支持这种方式.
那么,如果我只是想要原始HTML,那么我对此的期望是什么?删除前置的"module.exports ="字符串是不好的做法?从bundle编辑:删除'modules.export ='部分结果在bundle中什么都不返回:/
我的配置
module.exports =
{
module:
{
loaders:
[
{ test: /\.html$/, loader: "raw-loader" }
]
}
};
Run Code Online (Sandbox Code Playgroud) 我需要覆盖文件/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Extension/AssetsExtension.php
它使用twig函数'asset'从bundle中加载twig getAssetUrl
/**
* Returns a list of functions to add to the existing list.
*
* @return array An array of functions
*/
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('asset', array($this, 'getAssetUrl')),
new \Twig_SimpleFunction('assets_version', array($this, 'getAssetsVersion')),
);
}
Run Code Online (Sandbox Code Playgroud)
我想覆盖asset()twig函数而不触及核心文件,否则将被下一个symfony更新覆盖
我写了一个简单的模板
的test.html
<div>raw text with content</div>
Run Code Online (Sandbox Code Playgroud)
我想做的就是要求原始文件,不做任何修改
喜欢
require('./test.html'); // should return "<div>raw text with content</div>"
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用extra-text-plugin加载html,但它不起作用
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports =
{
module:
{
loaders:
[
{ test: /\.html$/, loader: 'html' }
]
},
plugins: [
new ExtractTextPlugin("[name].html")
]
};
Run Code Online (Sandbox Code Playgroud) 它如何呈现它
1 2 3 > >> (page numbers, next button, last page button)
Run Code Online (Sandbox Code Playgroud)
我需要它如何呈现
> (only next button)
Run Code Online (Sandbox Code Playgroud)
如何在twig文件上触发render方法
<div class="pagination">
{{ knp_pagination_render(pagination) }}
</div>
Run Code Online (Sandbox Code Playgroud)
也许这会有所帮助,这是knp paginator源代码中的render函数
/**
* Renders the pagination template
*
* @param string $template
* @param array $queryParams
* @param array $viewParams
*
* @return string
*/
public function render($pagination, $template = null, array $queryParams = array(), array $viewParams = array())
{
return $this->environment->render(
$template ?: $pagination->getTemplate(),
$this->processor->render($pagination, $queryParams, $viewParams)
);
}
/**
* Get name …
Run Code Online (Sandbox Code Playgroud) 因此,我需要配置应用程序的公用文件夹,换句话说,我希望资产指向生成的索引文件上的自己的路径,例如src =“ mypublicpath / assets / app.js”
我真的确定这是需要在angular-cli.json配置中设置的值。
这是我的档案
{
"project": {
"version": "1.0.0-beta.28.3",
"name": "ng-app-manager"
},
"apps": [
{
"root": "src",
"outDir": "../bundles/ng-app-manager",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"files": "src/**/*.ts",
"project": "src/tsconfig.json"
},
{
"files": "e2e/**/*.ts",
"project": "e2e/tsconfig.json"
} …
Run Code Online (Sandbox Code Playgroud) 我已经尝试让 Angular 更新服务变量“open_popup”好几天了,但没有成功。
太长了;我想做的是,每当变量“open_popup”发生变化时,使其在组件上发生变化,也能够从组件函数中更改服务变量。
这是我到目前为止所尝试过的。
应用程序/src/app/audience-creator/shared/audience-creator.service.ts
import { Injectable } from "@angular/core";
import {Observable} from "rxjs/index";
import { of } from "rxjs/index";
@Injectable()
export class AudienceCreatorService {
constructor(private http: HttpClient) {}
public open_popup = false;
public toggleCreatorPopup() {
this.open_popup = !this.open_popup;
}
popupIsOpen(): Observable<any> {
return of(this.open_popup);
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序/src/app/audience-creator/audience-creator.component.ts
import {Stuff} from "@angular/core";
@Component({
selector: 'audience-creator',
templateUrl: 'audience-creator.html'
})
export class AudienceCreatorComponent implements AfterViewInit, OnInit {
public popup_is_open = false;
@Input()
audience_creator_service;
ngOnInit() {
this.audience_creator_service.popupIsOpen().subscribe(
popup_is_open => this.popup_is_open = …
Run Code Online (Sandbox Code Playgroud) .bookmarkRibbon{
width:0;
height:100px;
border-right:50px solid blue;
border-left:50px solid blue;
border-bottom:30px solid transparent;
}
<div class="bookmarkRibbon"></div>
Run Code Online (Sandbox Code Playgroud)
我正在努力制作这种形状的版本,其中功能区指向右而不是向下,我怎样才能实现这一目标?
Workbox无法在Chrome上运行,但在其他任何地方都可以使用,具有讽刺意味的是,由于我认为这是Google图书馆,因此显示的错误是:
Uncaught (in promise) DOMException : sw.js line 1
Run Code Online (Sandbox Code Playgroud)
铬:
我正在使用workbox-webpack-plugin
webpack.config.js
const workbox = require('workbox-webpack-plugin');
module.exports = {
plugins: [
new workbox.GenerateSW({
swDest: './service-worker.js',
skipWaiting: true,
clientsClaim: true
})
]
}
Run Code Online (Sandbox Code Playgroud)
index.ts(条目)
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/js/app/dist/service-worker.js');
});
}
Run Code Online (Sandbox Code Playgroud)
编辑:这是引发错误的代码行
编辑2:它实际上在icognito模式下工作,删除浏览器数据仍然无济于事。
编辑3:更新到最新的beta 1甚至更糟,因为除了最后一个错误,它将显示另一个错误,但是,此版本也可以在Chrome的icognito模式和其他浏览器中使用。
所以我得到了这个源代码
//get activated bundles
$bundle_list = new AutoRouter('dev',true);
$bundle_list = $bundle_list->getActivatedBundles();
for($a =0; $a < sizeof($bundle_list); $a++)
{
var_dump($bundle_list[$a]);
}
Run Code Online (Sandbox Code Playgroud)
转储返回几个这样的对象
object(Symfony\Bundle\FrameworkBundle\FrameworkBundle)[38]
protected 'name' => null
protected 'extension' => null
protected 'path' => null
protected 'container' => null
object(Symfony\Bundle\SecurityBundle\SecurityBundle)[41]
protected 'name' => null
protected 'extension' => null
protected 'path' => null
protected 'container' => null
object(Symfony\Bundle\TwigBundle\TwigBundle)[40]
protected 'name' => null
protected 'extension' => null
protected 'path' => null
protected 'container' => null
Run Code Online (Sandbox Code Playgroud)
我需要将对象名称提取为这样的字符串:
(string) "Symfony\Bundle\FrameworkBundle\FrameworkBundle"
(string) "Symfony\Bundle\SecurityBundle\SecurityBundle"
(string) "Symfony\Bundle\TwigBundle\TwigBundle"
Run Code Online (Sandbox Code Playgroud)
就像是 …
我需要根据值是否为真来设置样式.我需要这样的东西:
<div class="container" [ngStyle]="{ is_root_node: 'box-shadow: none;'}">
<div class="toolbar-container"></div>
<div/>
Run Code Online (Sandbox Code Playgroud)
我需要删除image_id = x适用的所有行
DELETE FROM `ImageVoters` WHERE image_id =1
Run Code Online (Sandbox Code Playgroud)
如何使用DQL执行此操作?
由于我试图一次删除几行,remove()函数将无法正常工作
EntityManager#remove() expects parameter 1 to be an entity object, array given.
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery('SELECT u FROM GabrielUploadBundle:ImageVoters u WHERE u.image_id = 1');
$db_imageactions = $query->getResult();
$em->remove($db_imageactions);
$em->flush();
Run Code Online (Sandbox Code Playgroud)
这是有效的代码
$qb = $em->createQueryBuilder();
$qb->delete('GabrielUploadBundle:ImageVoters', 'v')
->where($qb->expr()->eq('v.image_id', ':imageId'))
->setParameter('imageId', $current_imageId);
$qb->getQuery()->execute();
Run Code Online (Sandbox Code Playgroud) 它很简单,它删除了所有样式标签.下面的代码正是我想要的
$('*').removeAttr('style');
Run Code Online (Sandbox Code Playgroud)
现在我需要在没有jquery的情况下做同样的事情,因为我的整个代码是在没有jquery的情况下编写的,我不想为这个简单的任务包含库
除此之外,这是我到目前为止所尝试的,但它不起作用
document.getElementsByTagName('*').style.cssText = null;
document.getElementsByTagName('*').style.cssText = "";
document.getElementsByTagName('*').removeAttribute("style");
Run Code Online (Sandbox Code Playgroud)
解
var allstyles= document.getElementsByTagName('*');
for(var a=0; a<allstyles.length; a++)
{
allstyles[a].removeAttribute("style");
}
Run Code Online (Sandbox Code Playgroud) 我基本上有以下目录结构
这是index.php
use Scripts\htmlCrawler;
class Main
{
public function init()
{
$htmlCrawler = new htmlCrawler();
$htmlCrawler->sayHello();
}
}
$main = new Main();
$main->init();
Run Code Online (Sandbox Code Playgroud)
这是 /Scripts/htmlCrawler.php
namespace Scripts;
class htmlCrawler
{
public function sayHello()
{
return 'sfs';
}
}
Run Code Online (Sandbox Code Playgroud)
代码抛出以下错误
致命错误:在第 9 行 /mnt/htdocs/Spielwiese/MiniCrawler/index.php 中找不到类“Scripts\htmlCrawler”
angular ×3
javascript ×3
php ×3
symfony ×3
webpack ×3
html ×2
node.js ×2
npm ×2
twig ×2
angular-cli ×1
angular6 ×1
css ×1
css-shapes ×1
doctrine-orm ×1
dql ×1
knppaginator ×1
namespaces ×1
pagination ×1
php-5.5 ×1
raw-loader ×1
typescript ×1
workbox ×1